mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-14 19:43:50 +01:00
Revert "improve mxid check performance"
This commit is contained in:
parent
725a72ec5a
commit
f92963f5db
1 changed files with 3 additions and 4 deletions
|
@ -12,11 +12,11 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import string
|
||||||
|
|
||||||
from synapse.api.errors import SynapseError
|
from synapse.api.errors import SynapseError
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class Requester(namedtuple("Requester", [
|
class Requester(namedtuple("Requester", [
|
||||||
|
@ -214,8 +214,7 @@ class GroupID(DomainSpecificString):
|
||||||
return group_id
|
return group_id
|
||||||
|
|
||||||
|
|
||||||
# A regex that matches any valid mxid characters
|
mxid_localpart_allowed_characters = set("_-./=" + string.ascii_lowercase + string.digits)
|
||||||
MXID_LOCALPART_REGEX = re.compile("^[_\-./=a-z0-9]*$")
|
|
||||||
|
|
||||||
|
|
||||||
def contains_invalid_mxid_characters(localpart):
|
def contains_invalid_mxid_characters(localpart):
|
||||||
|
@ -227,7 +226,7 @@ def contains_invalid_mxid_characters(localpart):
|
||||||
Returns:
|
Returns:
|
||||||
bool: True if there are any naughty characters
|
bool: True if there are any naughty characters
|
||||||
"""
|
"""
|
||||||
return not MXID_LOCALPART_REGEX.match(localpart)
|
return any(c not in mxid_localpart_allowed_characters for c in localpart)
|
||||||
|
|
||||||
|
|
||||||
class StreamToken(
|
class StreamToken(
|
||||||
|
|
Loading…
Reference in a new issue