You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/03/31 08:59:56 UTC

[incubator-ponymail-foal] 01/02: Ensure all new values are strings

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit cc5cdfab97740c7917fd2e583428e69a8e6663e2
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Wed Mar 31 10:58:50 2021 +0200

    Ensure all new values are strings
---
 server/endpoints/mgmt.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/server/endpoints/mgmt.py b/server/endpoints/mgmt.py
index 808664a..9002e05 100644
--- a/server/endpoints/mgmt.py
+++ b/server/endpoints/mgmt.py
@@ -69,6 +69,13 @@ async def process(
         new_list = "<" + indata.get("list", "").strip("<>").replace("@", ".") + ">"  # foo@bar.baz -> <foo.bar.baz>
         private = True if indata.get("private", "no") == "yes" else False
         new_body = indata.get("body")
+
+        # Check for consistency so we don't pollute the database
+        assert isinstance(new_from, str), "Author field must be a text string!"
+        assert isinstance(new_subject, str), "Subject field must be a text string!"
+        assert isinstance(new_list, str), "List ID field must be a text string!"
+        assert isinstance(new_body, str), "Email body must be a text string!"
+
         email = await plugins.mbox.get_email(session, permalink=doc)
         if email and isinstance(email, dict) and plugins.aaa.can_access_email(session, email):
             email["from_raw"] = new_from