blob: f0c9909c3f859afc3323dfec3a6443b2164478ac [file] [log] [blame]
From 28a35d63a0cc6b7beb51c77d93bb30778e6960cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com>
Date: Mon, 9 Dec 2019 13:41:47 +0100
Subject: [PATCH] Fixed the broken fix, when greedy regex ate the whole file.
We want to match attributes in an XML element, not in the whole file.
Upstream-Status: Backport
[https://github.com/ComplianceAsCode/content/commit/28a35d63a0cc6b7beb51c77d93bb30778e6960cd]
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
---
ssg/build_remediations.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/ssg/build_remediations.py b/ssg/build_remediations.py
index 13e90f732..edf31c0cf 100644
--- a/ssg/build_remediations.py
+++ b/ssg/build_remediations.py
@@ -57,10 +57,10 @@ def get_available_functions(build_dir):
with codecs.open(xmlfilepath, "r", encoding="utf-8") as xmlfile:
filestring = xmlfile.read()
# This regex looks implementation dependent but we can rely on the element attributes
- # being present on one line.
+ # being present. Beware, DOTALL means we go through the whole file at once.
# We can't rely on ElementTree sorting XML attrs in any way since Python 3.7.
remediation_functions = re.findall(
- r'<Value.*id=\"function_(\S+)\"',
+ r'<Value[^>]+id=\"function_(\S+)\"',
filestring, re.DOTALL
)
--
2.17.1