diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index cba2b5d04..aa07e613b 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -594,8 +594,13 @@ EMOJI_SRCS = ['files/assets/emojis.json'] PIN_LIMIT = 3 POST_TITLE_LENGTH_LIMIT = 500 # do not make larger than 500 without altering the table POST_TITLE_HTML_LENGTH_LIMIT = 1500 # do not make larger than 1500 without altering the table -POST_BODY_LENGTH_LIMIT = 20000 # do not make larger than 20000 without altering the table -POST_BODY_HTML_LENGTH_LIMIT = 40000 # do not make larger than 40000 without altering the table + +def POST_BODY_LENGTH_LIMIT(v): + if v.patron: return 100000 + return 20000 + +POST_BODY_HTML_LENGTH_LIMIT = 200000 # do not make larger than 200000 without altering the table + COMMENT_BODY_LENGTH_LIMIT = 10000 # do not make larger than 10000 characters without altering the table COMMENT_BODY_HTML_LENGTH_LIMIT = 20000 # do not make larger than 20000 characters without altering the table CSS_LENGTH_LIMIT = 10000 # do not make larger than 20000 characters without altering the table diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index cc2f59310..5244eb581 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -311,7 +311,7 @@ def sanitize_raw_body(sanitized:Optional[str], is_post:bool) -> str: sanitized = html_comment_regex.sub('', sanitized) sanitized = sanitized.replace('\u200e','').replace('\u200b','').replace("\ufeff", "").replace("\r\n", "\n") sanitized = sanitized.strip() - return sanitized[:POST_BODY_LENGTH_LIMIT if is_post else COMMENT_BODY_LENGTH_LIMIT] + return sanitized[:POST_BODY_LENGTH_LIMIT(g.v) if is_post else COMMENT_BODY_LENGTH_LIMIT] def sanitize_settings_text(sanitized:Optional[str], max_length:Optional[int]=None) -> str: diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index 2e02d269b..0ede24cec 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -110,7 +110,7 @@ def inject_constants(): "FP":FP, "patron":patron, "get_setting": get_setting, "SIDEBAR_THREAD":SIDEBAR_THREAD, "BANNER_THREAD":BANNER_THREAD, "BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD, - "approved_embed_hosts":approved_embed_hosts, + "approved_embed_hosts":approved_embed_hosts, "POST_BODY_LENGTH_LIMIT":POST_BODY_LENGTH_LIMIT, "SITE_SETTINGS":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see, "TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN, "TRUESCORE_DONATE_MINIMUM":TRUESCORE_DONATE_MINIMUM, "PROGSTACK_ID":PROGSTACK_ID, diff --git a/files/routes/posts.py b/files/routes/posts.py index 1cc5ca426..f905b0eeb 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -291,7 +291,7 @@ def edit_post(pid, v): p.title_html = title_html body = process_files(request.files, v, body) - body = body.strip()[:POST_BODY_LENGTH_LIMIT] # process_files() may be adding stuff to the body + body = body.strip()[:POST_BODY_LENGTH_LIMIT(v)] # process_files() may be adding stuff to the body if body != p.body: body, bets, options, choices = sanitize_poll_options(v, body, False) @@ -652,7 +652,7 @@ def submit_post(v:User, sub=None): body, bets, options, choices = sanitize_poll_options(v, body, True) body = process_files(request.files, v, body) - body = body.strip()[:POST_BODY_LENGTH_LIMIT] # process_files() adds content to the body, so we need to re-strip + body = body.strip()[:POST_BODY_LENGTH_LIMIT(v)] # process_files() adds content to the body, so we need to re-strip torture = (v.agendaposter and not v.marseyawarded and sub != 'chudrama') diff --git a/files/templates/submission.html b/files/templates/submission.html index 01d9082b1..ccd328a2f 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -168,7 +168,7 @@ - +
diff --git a/files/templates/submit.html b/files/templates/submit.html index 1d1d481eb..c18a18de4 100644 --- a/files/templates/submit.html +++ b/files/templates/submit.html @@ -49,8 +49,8 @@ You can upload images, videos, or audio. - - + +

diff --git a/migrations/20230228-increase-body-max-limit-for-patrons.sql b/migrations/20230228-increase-body-max-limit-for-patrons.sql new file mode 100644 index 000000000..7102c8178 --- /dev/null +++ b/migrations/20230228-increase-body-max-limit-for-patrons.sql @@ -0,0 +1,2 @@ +alter table submissions alter column body type varchar(100000); +alter table submissions alter column body_html type varchar(200000); diff --git a/schema.sql b/schema.sql index 3611f2027..1802ad01d 100644 --- a/schema.sql +++ b/schema.sql @@ -110,8 +110,8 @@ CREATE TABLE public.submissions ( stickied character varying(40), title character varying(500) NOT NULL, url character varying(2083), - body character varying(20000), - body_html character varying(40000), + body character varying(100000), + body_html character varying(200000), embed character varying(1500), ban_reason character varying(25), title_html character varying(1500) NOT NULL, @@ -2872,4 +2872,3 @@ ALTER TABLE ONLY public.comments -- -- PostgreSQL database dump complete -- -