diff options
author | Sean Quah <8349537+squahtx@users.noreply.github.com> | 2021-12-06 11:36:08 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-06 11:36:08 +0000 |
commit | a77c36989785c0d5565ab9a1169f4f88e512ce8a (patch) | |
tree | d3f095c83192afb66d4b33113a473e4d2d7ddbf5 /synapse/push | |
parent | Update backward extremity docs to make it clear that it does not indicate whe... (diff) | |
download | synapse-a77c36989785c0d5565ab9a1169f4f88e512ce8a.tar.xz |
Move `glob_to_regex` and `re_word_boundary` to `matrix-python-common` (#11505)
Diffstat (limited to 'synapse/push')
-rw-r--r-- | synapse/push/push_rule_evaluator.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/synapse/push/push_rule_evaluator.py b/synapse/push/push_rule_evaluator.py index 7f68092ec5..659a53805d 100644 --- a/synapse/push/push_rule_evaluator.py +++ b/synapse/push/push_rule_evaluator.py @@ -17,9 +17,10 @@ import logging import re from typing import Any, Dict, List, Optional, Pattern, Tuple, Union +from matrix_common.regex import glob_to_regex, to_word_pattern + from synapse.events import EventBase from synapse.types import JsonDict, UserID -from synapse.util import glob_to_regex, re_word_boundary from synapse.util.caches.lrucache import LruCache logger = logging.getLogger(__name__) @@ -184,7 +185,7 @@ class PushRuleEvaluatorForEvent: r = regex_cache.get((display_name, False, True), None) if not r: r1 = re.escape(display_name) - r1 = re_word_boundary(r1) + r1 = to_word_pattern(r1) r = re.compile(r1, flags=re.IGNORECASE) regex_cache[(display_name, False, True)] = r @@ -213,7 +214,7 @@ def _glob_matches(glob: str, value: str, word_boundary: bool = False) -> bool: try: r = regex_cache.get((glob, True, word_boundary), None) if not r: - r = glob_to_regex(glob, word_boundary) + r = glob_to_regex(glob, word_boundary=word_boundary) regex_cache[(glob, True, word_boundary)] = r return bool(r.search(value)) except re.error: |