diff options
author | David Robertson <davidr@element.io> | 2022-05-18 10:19:30 +0100 |
---|---|---|
committer | David Robertson <davidr@element.io> | 2022-05-18 10:19:30 +0100 |
commit | 0953cad3e4961ac7999373203cc91c3c7adcdfa4 (patch) | |
tree | f07ad801470457063f4f00eb0125b045e4745d59 | |
parent | go away flake8 (diff) | |
download | synapse-dmr/reject-null-codepoints-user-dir.tar.xz |
docstringggggg dmr/reject-null-codepoints-user-dir
-rw-r--r-- | synapse/util/stringutils.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/synapse/util/stringutils.py b/synapse/util/stringutils.py index 11246d95e9..27a363d7e5 100644 --- a/synapse/util/stringutils.py +++ b/synapse/util/stringutils.py @@ -250,4 +250,8 @@ def base62_encode(num: int, minwidth: int = 1) -> str: def non_null_str_or_none(val: Any) -> Optional[str]: + """Check that the arg is a string containing no null (U+0000) codepoints. + + If so, returns the given string unmodified; otherwise, returns None. + """ return val if isinstance(val, str) and "\u0000" not in val else None |