[asterisk-commits] mnicholson: branch mnicholson/failure-message r2441 - /asterisk/team/mnichols...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 23 15:17:11 CDT 2011


Author: mnicholson
Date: Fri Sep 23 15:17:07 2011
New Revision: 2441

URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=2441
Log:
ok this one should parse correctly

Modified:
    asterisk/team/mnicholson/failure-message/generate-results-xml.py

Modified: asterisk/team/mnicholson/failure-message/generate-results-xml.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/team/mnicholson/failure-message/generate-results-xml.py?view=diff&rev=2441&r1=2440&r2=2441
==============================================================================
--- asterisk/team/mnicholson/failure-message/generate-results-xml.py (original)
+++ asterisk/team/mnicholson/failure-message/generate-results-xml.py Fri Sep 23 15:17:07 2011
@@ -2,6 +2,20 @@
 # vim: sw=4 et:
 
 import xml.dom
+
+def strip_illegal_xml_chars(data):
+    ranges = [
+        (0x0, 0x8),
+        (0xb, 0xc),
+        (0xe, 0x1f),
+        (0x7f, 0x84),
+        (0x86, 0x9f),
+    ]
+    illegal = []
+    for r in ranges:
+        for i in range(r[0], r[1]+1):
+            illegal.append(chr(i))
+    return data.translate(None, ''.join(illegal))
 
 def testcase(name, failure = None):
     tc = doc.createElement("testcase")
@@ -9,7 +23,7 @@
     tc.setAttribute("name", name)
     if failure:
         f = doc.createElement("failure")
-        f.appendChild(doc.createTextNode(failure))
+        f.appendChild(doc.createTextNode(strip_illegal_xml_chars(failure)))
         tc.appendChild(f)
 
     return tc
@@ -27,7 +41,7 @@
 
 ts.appendChild(testcase("legal1"))
 ts.appendChild(testcase("escape1", "let's see if this get's escaped <> \" \' & ;"))
-ts.appendChild(testcase("illegal1", "going to drop some illegal chars in here\n bah, it just let it through"))
+ts.appendChild(testcase("stripped1", "going to drop some illegal chars in here  " + chr(0) + " and they should get stripped out"))
 
 doc.writexml(open('results.xml', 'w'), encoding = "utf-8")
 




More information about the asterisk-commits mailing list