Skip to content

Commit

Permalink
parser: Upgrade XML_IO_NETWORK_ATTEMPT to error
Browse files Browse the repository at this point in the history
Fixes XML::LibXML test suite.
  • Loading branch information
nwellnhof committed Jul 4, 2024
1 parent f86d17c commit ec08810
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions parserInternals.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,19 +219,20 @@ xmlCtxtErrIO(xmlParserCtxtPtr ctxt, int code, const char *uri)
if (ctxt == NULL)
return;

/*
* Only report a warning if a file could not be found. This should
* only be done for external entities, but the external entity loader
* of xsltproc can try multiple paths and assumes that ENOENT doesn't
* raise an error and aborts parsing.
*/
if (((code == XML_IO_ENOENT) ||
(code == XML_IO_NETWORK_ATTEMPT) ||
(code == XML_IO_UNKNOWN))) {
/*
* Only report a warning if a file could not be found. This should
* only be done for external entities, but the external entity loader
* of xsltproc can try multiple paths and assumes that ENOENT doesn't
* raise an error and aborts parsing.
*/
if (ctxt->validate == 0)
level = XML_ERR_WARNING;
else
level = XML_ERR_ERROR;
} else if (code == XML_IO_NETWORK_ATTEMPT) {
level = XML_ERR_ERROR;
} else {
level = XML_ERR_FATAL;
}
Expand Down
2 changes: 1 addition & 1 deletion python/tests/input_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def my_ctx_error_cb(arg, msg, severity, reserved):
run_test(desc="Loading entity with custom callback",
docpath=startURL, catalog=None,
exp_status="loaded", exp_err=[
( 3, 'failed to load "http://example.com/dtds/sample.dtd": Attempt to load network entity\n'),
( 4, 'failed to load "http://example.com/dtds/sample.dtd": Attempt to load network entity\n'),
( 4, "Entity 'sample.entity' not defined\n")
])

Expand Down

0 comments on commit ec08810

Please sign in to comment.