summaryrefslogtreecommitdiff
path: root/scripts/Util.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/Util.py')
-rw-r--r--scripts/Util.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/scripts/Util.py b/scripts/Util.py
index 11f768c3104..e8e4caf6744 100644
--- a/scripts/Util.py
+++ b/scripts/Util.py
@@ -52,12 +52,15 @@ def val(v, escapeQuotes=False, quoteValue=True):
else:
return str(v)
+illegalXMLChars = re.compile(u'[\x00-\x08\x0b\x0c\x0e-\x1F\uD800-\uDFFF\uFFFE\uFFFF]')
+
def escapeXml(s, attribute=False):
# Remove backspace characters from the output (they aren't accepted by Jenkins XML parser)
if isPython2:
s = "".join(ch for ch in unicode(s.decode("utf-8")) if ch != u"\u0008").encode("utf-8")
else:
s = "".join(ch for ch in s if ch != u"\u0008")
+ s = illegalXMLChars.sub("?", s) # Strip invalid XML characters
return xml.sax.saxutils.quoteattr(s) if attribute else xml.sax.saxutils.escape(s)
def getIceSoVersion():