mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-05-18 11:20:21 -04:00
Discard null-containing strings before updating the user directory (#12762)
This commit is contained in:
parent
8afb7b55d0
commit
d4713d3e33
6 changed files with 45 additions and 11 deletions
|
@ -16,7 +16,7 @@ import itertools
|
|||
import re
|
||||
import secrets
|
||||
import string
|
||||
from typing import Iterable, Optional, Tuple
|
||||
from typing import Any, Iterable, Optional, Tuple
|
||||
|
||||
from netaddr import valid_ipv6
|
||||
|
||||
|
@ -247,3 +247,11 @@ def base62_encode(num: int, minwidth: int = 1) -> str:
|
|||
# pad to minimum width
|
||||
pad = "0" * (minwidth - len(res))
|
||||
return pad + res
|
||||
|
||||
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue