blob: a7529e766b6e20ae6f8104f30b135fc8076094fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
From 3ef06fcb9ae55295a9df29b564ea9302809e12a7 Mon Sep 17 00:00:00 2001
From: Nick Wellnhofer <wellnhofer@aevum.de>
Date: Mon, 5 Aug 2024 14:58:37 +0200
Subject: [PATCH] parser: Fix error handling after reaching limit
Mark document as non-wellformed and stop parser even if error limit was
reached.
Regressed in abd74186.
parser: Report at least one fatal error
---
parserInternals.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/parserInternals.c b/parserInternals.c
index 7700de39..eb13be7e 100644
--- parserInternals.c
+++ parserInternals.c
@@ -327,11 +327,13 @@ xmlCtxtVErr(xmlParserCtxtPtr ctxt, xmlNodePtr node, xmlErrorDomain domain,
if (level == XML_ERR_WARNING) {
if (ctxt->nbWarnings >= XML_MAX_ERRORS)
- return;
+ goto done;
ctxt->nbWarnings += 1;
} else {
- if (ctxt->nbErrors >= XML_MAX_ERRORS)
- return;
+ /* Report at least one fatal error. */
+ if ((ctxt->nbErrors >= XML_MAX_ERRORS) &&
+ ((level < XML_ERR_FATAL) || (ctxt->wellFormed == 0)))
+ goto done;
ctxt->nbErrors += 1;
}
@@ -382,6 +384,7 @@ xmlCtxtVErr(xmlParserCtxtPtr ctxt, xmlNodePtr node, xmlErrorDomain domain,
return;
}
+done:
if (level >= XML_ERR_ERROR)
ctxt->errNo = code;
if (level == XML_ERR_FATAL) {
--
2.45.1
|