diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-02-19 00:14:00 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-02-19 00:15:10 +0100 |
commit | 4eea13b55a671eeef3078c8d589b628614296419 (patch) | |
tree | 37e7004c9881f91fd24df902dcb96f444a5c248c | |
parent | c2b5bcedad6f2afe5472319b4552ecb4558a3d40 (diff) | |
download | Ishtar-4eea13b55a671eeef3078c8d589b628614296419.tar.bz2 Ishtar-4eea13b55a671eeef3078c8d589b628614296419.zip |
Fix too expensive regexp
-rw-r--r-- | ishtar_common/ooo_replace.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/ishtar_common/ooo_replace.py b/ishtar_common/ooo_replace.py index 76ff81e73..5d75dce21 100644 --- a/ishtar_common/ooo_replace.py +++ b/ishtar_common/ooo_replace.py @@ -82,6 +82,7 @@ def _format_value(value, default_value): VAR_EXPR = u"###VAR %s###" WHOLE_KEY_FILTER = u"((?:(?: )*(?:<[^#>]*>)*(?: )*(?:[-a-zA-Z0-9_])*(?: )*)*)" +WHOLE_KEY_FILTER = u"([^#]*)" RE_VAR = re.compile(VAR_EXPR % WHOLE_KEY_FILTER) IF_EXPR = u"###IF %s###(.*)###ENDIF###" RE_IF = re.compile(IF_EXPR % WHOLE_KEY_FILTER) @@ -113,7 +114,7 @@ def _ishtar_parsing(context, value, default_value=''): """ for regexp, sub_exp, if_cond in ((RE_IF, IF_EXPR, True), (RE_VAR, VAR_EXPR, False)): - for base_key in regexp.findall(value): + for base_key in regexp.findall(value[:]): v, val = "", None if if_cond: # the value inside the if is parsed base_key, val = base_key |