Normalize line endings in form submissions

Fixes #506
This commit is contained in:
rubenwardy
2024-06-22 13:22:37 +01:00
parent d6e25f38a8
commit da090fd3f5
10 changed files with 29 additions and 21 deletions

View File

@@ -20,7 +20,7 @@ from flask_wtf import FlaskForm
from wtforms import StringField, TextAreaField, SubmitField
from wtforms.validators import InputRequired, Length, Optional, Regexp
from app.utils import rank_required
from app.utils import rank_required, normalize_line_endings
from . import bp
from app.models import UserRank, ContentWarning, db
@@ -33,7 +33,7 @@ def warning_list():
class WarningForm(FlaskForm):
title = StringField("Title", [InputRequired(), Length(3, 100)])
description = TextAreaField("Description", [Optional(), Length(0, 500)])
description = TextAreaField("Description", [Optional(), Length(0, 500)], filters=[normalize_line_endings])
name = StringField("Name", [Optional(), Length(1, 20),
Regexp("^[a-z0-9_]", 0, "Lower case letters (a-z), digits (0-9), and underscores (_) only")])
submit = SubmitField("Save")