Commit e9cf8bf
committed
gh-156796: Finalize the parser of an external entity in xml.sax
ExpatParser.close() returned early whenever _entity_stack was not empty,
so feed(b"", isFinal=True) was never called for the parser created by
external_entity_ref(). Expat therefore never checked the entity's input
for completeness, and an external entity whose content is not well-formed
was silently accepted. Errors expat detects while feeding data, such as a
mismatched tag, were still reported; only those detectable at the end of
the input, such as an unclosed element, were lost.
Finalize the entity's parser in that case, while still leaving the
document open, since the enclosing parse is what the early return was
there to protect.1 parent e7c93b7 commit e9cf8bf
3 files changed
Lines changed: 32 additions & 3 deletions
File tree
- Lib
- test
- xml/sax
- Misc/NEWS.d/next/Library
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
| 1054 | + | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
1042 | 1062 | | |
1043 | 1063 | | |
1044 | 1064 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
241 | | - | |
242 | | - | |
243 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
244 | 249 | | |
245 | 250 | | |
246 | 251 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
0 commit comments