From e62d0354e897f503b802625002644d10f8836e03 Mon Sep 17 00:00:00 2001 From: official-techsupport Date: Mon, 23 Jan 2023 22:58:51 +0200 Subject: [PATCH] fix an edge case in showmore (when many long paragraphs) --- files/helpers/sanitize.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index ef95632a0..e59314ef5 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -428,13 +428,14 @@ def sanitize(sanitized, golden=True, limit_pings=0, showmore=True, count_marseys if showmore: # Insert a show more button if the text is too long or has too many paragraphs + CHARLIMIT = 3000 pos = 0 for _ in range(20): pos = sanitized.find('

', pos + 4) if pos < 0: break - if pos < 0 and len(sanitized) > 3000: - pos = 2500 + if (pos < 0 and len(sanitized) > CHARLIMIT) or pos > CHARLIMIT: + pos = CHARLIMIT - 500 if pos >= 0: sanitized = (sanitized[:pos] + showmore_regex.sub(r'\1

\2', -- 2.34.1