File tree Expand file tree Collapse file tree 7 files changed +18
-5
lines changed
tests/saxparser_chunk_parsing_inconsistent_state Expand file tree Collapse file tree 7 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 16
16
17
17
#include < libxml/tree.h>
18
18
#include < libxml/xinclude.h>
19
+ #include < libxml/xmlsave.h>
19
20
#include < libxml/parser.h> // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX
20
21
21
22
#include < iostream>
Original file line number Diff line number Diff line change 8
8
#include < libxml++/exceptions/parse_error.h>
9
9
#include < libxml++/io/istreamparserinputbuffer.h>
10
10
11
- #include < libxml/tree .h>
11
+ #include < libxml/parser .h>
12
12
13
13
#include < sstream>
14
14
Original file line number Diff line number Diff line change 5
5
* included with libxml++ as the file COPYING.
6
6
*/
7
7
8
- #include < libxml++/keepblanks.h>
8
+ // xmlKeepBlanksDefault() is deprecated since libxml2 2.12.0.
9
+ // Ignore deprecations here.
10
+ #define XML_DEPRECATED
9
11
12
+ #include < libxml++/keepblanks.h>
10
13
#include < libxml/globals.h>
11
14
12
15
namespace xmlpp
Original file line number Diff line number Diff line change 5
5
*/
6
6
7
7
#include < libxml++/nodes/entitydeclaration.h>
8
- #include < libxml/tree .h>
8
+ #include < libxml/entities .h>
9
9
10
10
namespace xmlpp
11
11
{
Original file line number Diff line number Diff line change 6
6
7
7
#include < libxml++/nodes/entityreference.h>
8
8
9
- #include < libxml/tree .h>
9
+ #include < libxml/entities .h>
10
10
11
11
namespace xmlpp
12
12
{
Original file line number Diff line number Diff line change 22
22
#include " libxml++/parsers/domparser.h"
23
23
#include " libxml++/relaxngschema.h"
24
24
25
+ #include < libxml/tree.h>
25
26
#include < libxml/relaxng.h>
26
27
27
28
namespace xmlpp
Original file line number Diff line number Diff line change 24
24
25
25
class MySaxParser : public xmlpp ::SaxParser
26
26
{
27
+ public:
28
+ bool throw_on_start_doc = true ;
29
+
27
30
protected:
28
31
void on_start_document () override
29
32
{
30
- throw std::runtime_error (" some custom runtime exception" );
33
+ if (throw_on_start_doc)
34
+ throw std::runtime_error (" some custom runtime exception" );
31
35
}
32
36
void on_error (const xmlpp::ustring& /* text */ ) override
33
37
{
@@ -43,6 +47,9 @@ int main()
43
47
bool exceptionThrown = false ;
44
48
try
45
49
{
50
+ // Depending on the libxml2 version, MySaxParser::on_start_document()
51
+ // may or may not be called before MySaxParser::on_error().
52
+ parser.throw_on_start_doc = false ;
46
53
parser.parse_chunk (" <?" );
47
54
parser.finish_chunk_parsing ();
48
55
}
@@ -61,6 +68,7 @@ int main()
61
68
exceptionThrown = false ;
62
69
try
63
70
{
71
+ parser.throw_on_start_doc = true ;
64
72
std::stringstream ss (" <root></root>" );
65
73
parser.parse_stream (ss);
66
74
}
You can’t perform that action at this time.
0 commit comments