libtest: Stricter XML validation
Expect the entire input to be a single XML document, instead of reading it line by line. This detects trailing junk better.
This commit is contained in:
parent
cc3eee7fbe
commit
e39e127bd0
1 changed files with 7 additions and 7 deletions
|
|
@ -13,10 +13,10 @@
|
|||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
# Try to decode line in order to ensure it is a valid XML document
|
||||
for line in sys.stdin:
|
||||
try:
|
||||
ET.fromstring(line)
|
||||
except ET.ParseError:
|
||||
print("Invalid xml: %r" % line)
|
||||
raise
|
||||
# Read the entire output and try to decode it as XML.
|
||||
junit = sys.stdin.read()
|
||||
try:
|
||||
ET.fromstring(junit)
|
||||
except ET.ParseError:
|
||||
print("Invalid xml: %r" % junit)
|
||||
raise
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue