From b8978e0cb0100ef7ef8c09ca0a452cd495969dd7 Mon Sep 17 00:00:00 2001 From: shaohuzhang1 Date: Wed, 6 May 2026 11:00:41 +0800 Subject: [PATCH] fix: Judge regular matching using fullmatch --- apps/application/flow/compare/regex_compare.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/application/flow/compare/regex_compare.py b/apps/application/flow/compare/regex_compare.py index eeb76a5256e..613300e6589 100644 --- a/apps/application/flow/compare/regex_compare.py +++ b/apps/application/flow/compare/regex_compare.py @@ -11,12 +11,11 @@ from .compare import Compare from common.cache.mem_cache import MemCache - match_cache = MemCache('regex', { - 'TIMEOUT': 3600, # 缓存有效期为 1 小时 + 'TIMEOUT': 3600, # 缓存有效期为 1 小时 'OPTIONS': { - 'MAX_ENTRIES': 500, # 最多缓存 500 个条目 - 'CULL_FREQUENCY': 10, # 达到上限时,删除约 1/10 的缓存 + 'MAX_ENTRIES': 500, # 最多缓存 500 个条目 + 'CULL_FREQUENCY': 10, # 达到上限时,删除约 1/10 的缓存 }, }) @@ -24,10 +23,11 @@ def compile_and_cache(regex): match = match_cache.get(regex) if not match: - match = re.compile(regex).match + match = re.compile(regex).fullmatch match_cache.set(regex, match) return match + class RegexCompare(Compare): def compare(self, source_value, compare, target_value):