Skip to content

Commit e39e127

Browse files
committed
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.
1 parent cc3eee7 commit e39e127

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/run-make/libtest-junit/validate_junit.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import sys
1414
import xml.etree.ElementTree as ET
1515

16-
# Try to decode line in order to ensure it is a valid XML document
17-
for line in sys.stdin:
18-
try:
19-
ET.fromstring(line)
20-
except ET.ParseError:
21-
print("Invalid xml: %r" % line)
22-
raise
16+
# Read the entire output and try to decode it as XML.
17+
junit = sys.stdin.read()
18+
try:
19+
ET.fromstring(junit)
20+
except ET.ParseError:
21+
print("Invalid xml: %r" % junit)
22+
raise

0 commit comments

Comments
 (0)