From 04dfd77de57389be7f1cd8c68dd76b09f43d3009 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 6 Nov 2024 17:16:00 +0100 Subject: [PATCH] Fixing split_parts() in lib/pp_admintools/common.py --- lib/pp_admintools/common.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/pp_admintools/common.py b/lib/pp_admintools/common.py index 6ca850c..1bb6985 100644 --- a/lib/pp_admintools/common.py +++ b/lib/pp_admintools/common.py @@ -34,7 +34,7 @@ except ImportError: _ = XLATOR.gettext ngettext = XLATOR.ngettext -__version__ = '0.2.0' +__version__ = '0.2.1' LOG = logging.getLogger(__name__) @@ -57,7 +57,7 @@ RE_SPLIT_SQ = re.compile(r"\\'") RE_SPLIT_SQ_CHUNK = re.compile(r"^'((?:\\'|[^'])*)'") RE_SPLIT_DQ = re.compile(r'\\"') RE_SPLIT_DQ_CHUNK = re.compile(r'^"((?:\\"|[^"])*)"') -RE_SPLIT_UQ_CHUNK = re.compile(r'^((?:[^\s\'"]+|\\\'|\\")+)') +RE_SPLIT_UQ_CHUNK = re.compile("^((?:[^\\s'\"]|\\'|\\\")+)") RE_SPLIT_WS_ALL = re.compile(r'^\s*$') RE_SPLIT_UNBALANCED = re.compile(r'^([\'"].*)\s*') @@ -205,7 +205,7 @@ def split_parts(text, keep_quotes=False, raise_on_unbalanced=True): match = RE_SPLIT_DQ_CHUNK.search(txt) if match: chunk = match.group(1) - chunk = RE_SPLIT_DQ('"', chunk) + chunk = RE_SPLIT_DQ.sub('"', chunk) if keep_quotes: chunk = '"' + chunk + '"' last_chunk += chunk @@ -216,6 +216,8 @@ def split_parts(text, keep_quotes=False, raise_on_unbalanced=True): match = RE_SPLIT_UQ_CHUNK.search(txt) if match: last_chunk += match.group(1) + last_chunk = RE_SPLIT_SQ.sub("'", last_chunk) + last_chunk = RE_SPLIT_DQ.sub('"', last_chunk) txt = RE_SPLIT_UQ_CHUNK.sub('', txt) continue -- 2.39.5