summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis@fehcom.de>2024-11-17 23:00:31 +0100
committerJannis M. Hoffmann <jannis@fehcom.de>2024-11-17 23:00:31 +0100
commit83ab9b0b3f26f2a26b8f59737a725119dee7c515 (patch)
tree0c9d90a5c32ed2e9c82f02176471caf5bcef29ad
parentf1cfca6abd8a3db74c3c737fe1d950c4f3011992 (diff)
keep get parameters over post request on move/remove
increase character limit on password length form validation
-rw-r--r--src/jwebmail/__init__.py2
-rw-r--r--src/jwebmail/render_mail.py6
-rw-r--r--src/jwebmail/templates/_bot_nav.html6
-rw-r--r--src/jwebmail/webmail.py20
4 files changed, 27 insertions, 7 deletions
diff --git a/src/jwebmail/__init__.py b/src/jwebmail/__init__.py
index aecc817..67018ce 100644
--- a/src/jwebmail/__init__.py
+++ b/src/jwebmail/__init__.py
@@ -36,7 +36,7 @@ else:
toml_read_file = dict(load=toml_load, text=True)
-__version__ = "2.6.0.dev4"
+__version__ = "2.6.0.dev5"
csrf = CSRFProtect()
diff --git a/src/jwebmail/render_mail.py b/src/jwebmail/render_mail.py
index c36150d..7dc0824 100644
--- a/src/jwebmail/render_mail.py
+++ b/src/jwebmail/render_mail.py
@@ -11,7 +11,7 @@ def render_text_html(_subtype, _content, path):
if path:
url = url_for(
"read",
- folder=request.view_args.get("folder", ""),
+ folder=request.view_args.get("folder"),
msgid=request.view_args["msgid"],
format="raw",
path=".".join(map(str, path)),
@@ -19,7 +19,7 @@ def render_text_html(_subtype, _content, path):
else:
url = url_for(
"read",
- folder=request.view_args.get("folder", ""),
+ folder=request.view_args.get("folder"),
msgid=request.view_args["msgid"],
format="raw",
)
@@ -78,7 +78,7 @@ def render_multipart(_subtype, content, path):
ref_url = url_for(
"read",
- folder=request.view_args.get("folder", ""),
+ folder=request.view_args.get("folder"),
msgid=request.view_args["msgid"],
path=".".join(map(str, [*path, i])),
format="raw",
diff --git a/src/jwebmail/templates/_bot_nav.html b/src/jwebmail/templates/_bot_nav.html
index 73a5170..2634151 100644
--- a/src/jwebmail/templates/_bot_nav.html
+++ b/src/jwebmail/templates/_bot_nav.html
@@ -9,6 +9,9 @@
{% if mail_folders|length > 1 %}
<form action="{{ url_for('move', folder=folder) }}" id="move-mail" class=is-pulled-left method=POST>
<input type=hidden name=csrf_token value="{{ csrf_token() }}">
+ <input type=hidden name=sort value="{{ request.args['sort'] }}">
+ <input type=hidden name=per_page value="{{ request.args['per_page'] }}">
+ <input type=hidden name=page value="{{ request.args['page'] }}">
<div class="field has-addons">
<div class=control>
<div class=select>
@@ -32,6 +35,9 @@
method=POST class="is-pulled-left ml-2">
<input type=hidden name=csrf_token value="{{ csrf_token() }}">
+ <input type=hidden name=sort value="{{ request.args['sort'] }}">
+ <input type=hidden name=per_page value="{{ request.args['per_page'] }}">
+ <input type=hidden name=page value="{{ request.args['page'] }}">
<div class=control>
<input id=remove type=submit class=button value="{{ gettext('Remove') }}">
</div>
diff --git a/src/jwebmail/webmail.py b/src/jwebmail/webmail.py
index 1b61daa..84cb6a7 100644
--- a/src/jwebmail/webmail.py
+++ b/src/jwebmail/webmail.py
@@ -36,7 +36,7 @@ from .render_mail import to_mime_type
class LoginForm(FlaskForm):
username = StringField(lazy_gettext("Username"), [validators.Email()])
password = PasswordField(
- lazy_gettext("Password"), [validators.Length(min=5, max=35)]
+ lazy_gettext("Password"), [validators.Length(min=5, max=120)]
)
@@ -186,6 +186,18 @@ def writemail():
return render_template("writemail.html", form=WriteForm())
+def _take_common_req_args(mapping):
+ print(mapping)
+ res = dict()
+ if mapping.get("sort"):
+ res["sort"] = mapping["sort"]
+ if mapping.get("per_page"):
+ res["per_page"] = mapping["per_page"]
+ if mapping.get("page"):
+ res["page"] = mapping["page"]
+ return res
+
+
def move(folder=""):
folders = get_read_mails_logged_in().folders()
@@ -199,7 +211,8 @@ def move(folder=""):
get_read_mails_logged_in().move(m, folder, to_folder)
flash(gettext("succ_move"))
- return redirect(url_for("displayheaders", folder=folder), 303)
+ args = _take_common_req_args(request.form)
+ return redirect(url_for("displayheaders", folder=folder, **args), 303)
def remove(folder=""):
@@ -220,7 +233,8 @@ def remove(folder=""):
get_read_mails_logged_in().move(m, folder, "Trash")
flash(gettext("succ_remove"))
- return redirect(url_for("displayheaders", folder=folder), 303)
+ args = _take_common_req_args(request.form)
+ return redirect(url_for("displayheaders", folder=folder, **args), 303)
def sendmail():