summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2019-11-21 14:19:52 +0100
committerRadomir Dopieralski <openstack@sheep.art.pl>2019-11-21 14:21:50 +0100
commita6acf8236ce0322b8856f06a9c589d8f40851dc5 (patch)
tree9c588902cf42585d18ee3a10ffe6721f9dccee65
parented70bd3cd10eae2a34a5e9bd5d1fe0a6791ab3de (diff)
downloadoslo-utils-a6acf8236ce0322b8856f06a9c589d8f40851dc5.tar.gz
Fix invalid escapes in regular expression strings
The "r" for raw strings has to repeated when several strings are concatenated, otherwise the backslash in the strings that miss the "r" are interpreted directly, and result in invalid escapes. Change-Id: I3736a40043c8aa6c36c21803bf68f842af5cd55e
-rw-r--r--oslo_utils/strutils.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/oslo_utils/strutils.py b/oslo_utils/strutils.py
index 40c45dd..726f2dd 100644
--- a/oslo_utils/strutils.py
+++ b/oslo_utils/strutils.py
@@ -83,11 +83,11 @@ _FORMAT_PATTERNS_2 = [r'(%(key)s[0-9]*\s*[=]\s*[\"\'])[^\"\']*([\"\'])',
r'([-]{2}%(key)s[0-9]*\s+)[^\'^\"^=^\s]+([\s]*)',
r'(<%(key)s[0-9]*>)[^<]*(</%(key)s[0-9]*>)',
r'([\"\']%(key)s[0-9]*[\"\']\s*:\s*[\"\'])[^\"\']*'
- '([\"\'])',
+ r'([\"\'])',
r'([\'"][^"\']*%(key)s[0-9]*[\'"]\s*:\s*u?[\'"])[^\"\']*'
- '([\'"])',
+ r'([\'"])',
r'([\'"][^\'"]*%(key)s[0-9]*[\'"]\s*,\s*\'--?[A-z]+'
- '\'\s*,\s*u?[\'"])[^\"\']*([\'"])',
+ r'\'\s*,\s*u?[\'"])[^\"\']*([\'"])',
r'(%(key)s[0-9]*\s*--?[A-z]+\s*)\S+(\s*)']
# NOTE(dhellmann): Keep a separate list of patterns by key so we only