Skip to content

Commit 3471036

Browse files
committed
Wrap strings for XML checks so they're always valid XML.
1 parent e40c7a4 commit 3471036

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

aws_doc_sdk_examples_tools/metadata_validator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def _validate_aws_entity_usage(value: str) -> bool:
165165
Count all bare AWS occurrences overall.
166166
If these counts differ, there's an invalid usage.
167167
"""
168-
xtree = xml_tree.fromstring(f"<fake>{value.replace('&', '&amp;')}</fake>")
168+
xval = value.replace('&', '&amp;')
169+
xtree = xml_tree.fromstring(f"<fake><para>{xval}</para></fake>")
169170
blocks = xtree.findall("programlisting") + xtree.findall("code") + xtree.findall("noloc")
170171
aws_in_blocks = 0
171172
for element in blocks:

0 commit comments

Comments
 (0)