increase charlimit for bio, friends, and enemies to 5k

master
Aevann 2023-03-03 06:19:52 +02:00
parent 3b5d3cde4b
commit 2112626910
6 changed files with 31 additions and 21 deletions

View File

@ -610,6 +610,9 @@ MIN_REPOST_CHECK_URL_LENGTH = 9 # also change the constant in checkRepost() of s
CHAT_LENGTH_LIMIT = 1000 CHAT_LENGTH_LIMIT = 1000
SUB_BANNER_LIMIT = 10 SUB_BANNER_LIMIT = 10
BIO_FRIENDS_ENEMIES_LENGTH_LIMIT = 5000 # do not make larger than 5000 characters without altering the table
BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT = 20000 # do not make larger than 20000 characters without altering the table
COSMETIC_AWARD_COIN_AWARD_PCT = 0.10 COSMETIC_AWARD_COIN_AWARD_PCT = 0.10
TRUESCORE_CHAT_MINIMUM = 0 TRUESCORE_CHAT_MINIMUM = 0

View File

@ -118,5 +118,7 @@ def inject_constants():
"HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS), "HOUSE_JOIN_COST":HOUSE_JOIN_COST, "HOUSE_SWITCH_COST":HOUSE_SWITCH_COST, "IMAGE_FORMATS":','.join(IMAGE_FORMATS),
"PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS, "PAGE_SIZES":PAGE_SIZES, "THEMES":THEMES, "COMMENT_SORTS":COMMENT_SORTS, "SORTS":SORTS,
"TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME, "TIME_FILTERS":TIME_FILTERS, "HOUSES":HOUSES, "TIERS_ID_TO_NAME":TIERS_ID_TO_NAME,
"DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users, "gitref":git_head(), "SHOW_MORE": SHOW_MORE, "DEFAULT_CONFIG_VALUE":DEFAULT_CONFIG_VALUE, "IS_LOCALHOST":IS_LOCALHOST, "BACKGROUND_CATEGORIES":BACKGROUND_CATEGORIES, "PAGE_SIZE":PAGE_SIZE, "TAGLINES":TAGLINES, "IS_FISTMAS":IS_FISTMAS, "get_alt_graph":get_alt_graph, "current_registered_users":current_registered_users,
"gitref":git_head(), "SHOW_MORE": SHOW_MORE,
"BIO_FRIENDS_ENEMIES_LENGTH_LIMIT":BIO_FRIENDS_ENEMIES_LENGTH_LIMIT,
} }

View File

@ -245,16 +245,16 @@ def settings_personal_post(v):
msg="Your sig has been updated.") msg="Your sig has been updated.")
elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("friends"): elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("friends"):
friends = request.values.get("friends")[:1000] friends = request.values.get("friends")[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT]
friends_html = sanitize(friends, blackjack="friends") friends_html = sanitize(friends, blackjack="friends")
if len(friends_html) > 5000: if len(friends_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT:
return render_template("settings/personal.html", return render_template("settings/personal.html",
v=v, v=v,
error="Your friends list is too long") error="Your friends list is too long")
friends = friends[:1000] friends = friends[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT]
notify_users = NOTIFY_USERS(friends, v, v.friends) notify_users = NOTIFY_USERS(friends, v, v.friends)
@ -276,16 +276,16 @@ def settings_personal_post(v):
elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("enemies"): elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and request.values.get("enemies"):
enemies = request.values.get("enemies")[:1000] enemies = request.values.get("enemies")[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT]
enemies_html = sanitize(enemies, blackjack="enemies") enemies_html = sanitize(enemies, blackjack="enemies")
if len(enemies_html) > 5000: if len(enemies_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT:
return render_template("settings/personal.html", return render_template("settings/personal.html",
v=v, v=v,
error="Your enemies list is too long") error="Your enemies list is too long")
enemies = enemies[:1000] enemies = enemies[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT]
notify_users = NOTIFY_USERS(enemies, v, v.enemies) notify_users = NOTIFY_USERS(enemies, v, v.enemies)
if notify_users: if notify_users:
@ -307,19 +307,18 @@ def settings_personal_post(v):
elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and \ elif not updated and FEATURES['USERS_PROFILE_BODYTEXT'] and \
(request.values.get("bio") or request.files.get('file')): (request.values.get("bio") or request.files.get('file')):
bio = request.values.get("bio")[:1500] bio = request.values.get("bio")[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT]
bio = process_files(request.files, v, bio) bio = process_files(request.files, v, bio)
bio = bio.strip() bio = bio.strip()
bio_html = sanitize(bio, blackjack="bio") bio_html = sanitize(bio, blackjack="bio")
if len(bio_html) > 10000: if len(bio_html) > BIO_FRIENDS_ENEMIES_HTML_LENGTH_LIMIT:
return render_template("settings/personal.html", return render_template("settings/personal.html",
v=v, v=v,
error="Your bio is too long") error="Your bio is too long")
if len(bio_html) > 10000: abort(400)
v.bio = bio[:1500] v.bio = bio[:BIO_FRIENDS_ENEMIES_LENGTH_LIMIT]
v.bio_html=bio_html v.bio_html=bio_html
g.db.add(v) g.db.add(v)
return render_template("settings/personal.html", return render_template("settings/personal.html",

View File

@ -210,9 +210,9 @@
</div> </div>
{%- endif %} {%- endif %}
{# common.text_area_section(id, form_action, form_name, section_title, contents, below_text, placeholder_text, show_extras, show_file_upload, maxlength, show_if) #} {# common.text_area_section(id, form_action, form_name, section_title, contents, below_text, placeholder_text, show_extras, show_file_upload, maxlength, show_if) #}
{{common.text_area_section('profile-bio', '/settings/personal', 'bio', 'Bio', v.bio, 'Limit of 1500 characters', 'Tell the community a bit about yourself.', true, true, 1500, FEATURES['USERS_PROFILE_BODYTEXT'])}} {{common.text_area_section('profile-bio', '/settings/personal', 'bio', 'Bio', v.bio, 'Limit of ' ~ BIO_FRIENDS_ENEMIES_LENGTH_LIMIT ~ ' characters', 'Tell the community a bit about yourself.', true, true, BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, FEATURES['USERS_PROFILE_BODYTEXT'])}}
{{common.text_area_section('profile-friends', '/settings/personal', 'friends', 'Friends', v.friends, 'Limit of 500 characters', 'Enter your friends on the site...', false, false, 500, true)}} {{common.text_area_section('profile-friends', '/settings/personal', 'friends', 'Friends', v.friends, 'Limit of ' ~ BIO_FRIENDS_ENEMIES_LENGTH_LIMIT ~ ' characters', 'Enter your friends on the site...', false, false, BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, true)}}
{{common.text_area_section('profile-enemies', '/settings/personal', 'enemies', 'Enemies', v.enemies, 'Limit of 500 characters', 'Enter your enemies on the site...', false, false, 500, true)}} {{common.text_area_section('profile-enemies', '/settings/personal', 'enemies', 'Enemies', v.enemies, 'Limit of ' ~ BIO_FRIENDS_ENEMIES_LENGTH_LIMIT ~ ' characters', 'Enter your enemies on the site...', false, false, BIO_FRIENDS_ENEMIES_LENGTH_LIMIT, true)}}
{{common.text_area_section('profile-signature', '/settings/personal', 'sig', 'Signature', v.sig, 'Limit of 200 characters', 'Enter a signature...', true, false, 200, v.patron or v.sig)}} {{common.text_area_section('profile-signature', '/settings/personal', 'sig', 'Signature', v.sig, 'Limit of 200 characters', 'Enter a signature...', true, false, 200, v.patron or v.sig)}}
{# toggle_section(title, id, name, flag, below_text, disabled) #} {# toggle_section(title, id, name, flag, below_text, disabled) #}
{{common.toggle_section('Private Mode', 'privateswitch', 'private', v.is_private, 'This will hide your post and comment history from others. We will also ask search engines to not index your profile page. (Your content will still be accessible via direct link.)', false)}} {{common.toggle_section('Private Mode', 'privateswitch', 'private', v.is_private, 'This will hide your post and comment history from others. We will also ask search engines to not index your profile page. (Your content will still be accessible via direct link.)', false)}}

View File

@ -0,0 +1,7 @@
alter table users alter column bio type varchar(5000);
alter table users alter column friends type varchar(5000);
alter table users alter column enemies type varchar(5000);
alter table users alter column bio_html type varchar(20000);
alter table users alter column friends_html type varchar(20000);
alter table users alter column enemies_html type varchar(20000);

View File

@ -963,8 +963,8 @@ CREATE TABLE public.users (
admin_level integer DEFAULT 0 NOT NULL, admin_level integer DEFAULT 0 NOT NULL,
over_18 boolean DEFAULT false NOT NULL, over_18 boolean DEFAULT false NOT NULL,
is_activated boolean DEFAULT false NOT NULL, is_activated boolean DEFAULT false NOT NULL,
bio character varying(1500), bio character varying(5000),
bio_html character varying(10000), bio_html character varying(20000),
referred_by integer, referred_by integer,
is_banned integer, is_banned integer,
ban_reason character varying(256), ban_reason character varying(256),
@ -1015,11 +1015,11 @@ CREATE TABLE public.users (
marseyawarded integer, marseyawarded integer,
sig character varying(200), sig character varying(200),
sig_html character varying(1000), sig_html character varying(1000),
friends character varying(1000), friends character varying(5000),
friends_html character varying(5000), friends_html character varying(20000),
sigs_disabled boolean, sigs_disabled boolean,
enemies character varying(1000), enemies character varying(5000),
enemies_html character varying(5000), enemies_html character varying(20000),
fp character varying(21), fp character varying(21),
longpost integer, longpost integer,
bird integer, bird integer,
@ -2879,4 +2879,3 @@ ALTER TABLE ONLY public.comments
-- --
-- PostgreSQL database dump complete -- PostgreSQL database dump complete
-- --