1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-04-22 10:50:08 +03:00

6718 Commits

Author SHA1 Message Date
Nick Wellnhofer
0d170acaba io: Report malloc failure in xmlOutputBufferWrite
Fixes #676.
2024-02-01 11:51:58 +01:00
Nick Wellnhofer
2835337a1a doc: Mark xmllint --xpath as experimental
This feature was poorly thought-out.
2024-01-30 14:18:45 +01:00
Nick Wellnhofer
6b089473e0 doc: Update xmllint man page after fixing #180
Fixes #673.
2024-01-30 13:38:54 +01:00
Nick Wellnhofer
95f2a17440 parser: Fix crash in xmlParseInNodeContext with HTML documents
Ignore namespaces if we have an HTML document with namespaces added
manually.

Fixes #672.
2024-01-30 13:35:41 +01:00
Nick Wellnhofer
2e19d0ef04 SAX2: Make sure that OOM errors aren't overwritten 2024-01-26 11:39:51 +01:00
Nick Wellnhofer
12ce9b5ffe dict: Fix warnings with older clang 2024-01-25 20:41:42 +01:00
Nick Wellnhofer
8961056f9b parser: Make experimental input API private
This needs to be reworked.
2024-01-23 00:47:44 +01:00
Nick Wellnhofer
63986c45b9 parser: Report fatal error if document entity couldn't be loaded
Only lower error level when loading entities.

Fixes #667.
2024-01-22 21:07:41 +01:00
Nick Wellnhofer
37d474ff7e xpath: Fix return of empty node-set in xmlXPathNodeCollectAndTest
Don't return NULL node-sets. Ultimately, we should make sure that
obj->nodesetval is always non-NULL even for empty node-sets.

See #663.
2024-01-17 14:19:42 +01:00
Nick Wellnhofer
df618f08a6 tests: Add test for issue #661 2024-01-15 17:15:02 +01:00
Nick Wellnhofer
d636ef1de1 tests: Remove testOOM
This was never part of the standard test suite and we now test OOM error
handling more comprehensively with fuzz testing.
2024-01-11 00:43:44 +01:00
Nick Wellnhofer
24059ae92e autotools: Readd --with-xptr-locs configuration option
The option was removed accidentally in 4e4c89a4.
2024-01-10 18:10:10 +01:00
Nick Wellnhofer
29f4d69e2f xpath: Report malloc failure in xmlXPtrEvalXPtrPart 2024-01-10 16:02:33 +01:00
Nick Wellnhofer
2cebf2098d gitlab-ci: Disable Python tests on MinGW for now
See #658.
2024-01-10 15:58:23 +01:00
Nick Wellnhofer
57c687592f SAX2: Limit entity URI length to 2000 bytes
Avoid quadratic behavior when loading entities with long URIs multiple
times.

This limitation could be dropped if we cached external entities.
2024-01-10 15:58:23 +01:00
Nick Wellnhofer
6dc2fdb2bd parser: Account for full size of non-well-formed entities
Account for the full size of the entity if parsing stops because of
errors. In our cost model, we have to assume that the entity loader
processes the whole entity regardless of its content.
2024-01-10 15:58:23 +01:00
Nick Wellnhofer
29beef653c parser: Pop inputs if parsing DTD failed
This should provide some statistics in ctxt->sizeentcopy even in the
error or recovery case.
2024-01-10 15:58:23 +01:00
Nick Wellnhofer
02a2038de4 parser: Handle NOCDATA properly when expanding entities
Short-lived regression from e1153832.
2024-01-10 14:17:49 +01:00
Nick Wellnhofer
fd801845c8 fuzz: Cap URL size
Cap URL size to avoid quadratic behavior when generating error messages.
2024-01-07 16:33:30 +01:00
Nick Wellnhofer
83c1ae13d8 fuzz: Add missing include
Fix build failure.
2024-01-07 15:42:46 +01:00
Nick Wellnhofer
e1153832b0 parser: Fix quadratic behavior when copying entities
Process the first and last text node with the SAX handler to make the
text merging optimization kick in.

Fixes #657.
2024-01-07 15:42:39 +01:00
Nick Wellnhofer
d2b55a7a02 writer: Implement xmlTextWriterClose
This function can be used to make sure that closing the output stream
succeeded.

Fixes #513.
2024-01-05 20:50:00 +01:00
Nick Wellnhofer
f237e5b934 parser: Avoid duplicate namespace errors
Don't report an extra attribute uniqueness error if a namespace is
undeclared. This matches old behavior.
2024-01-05 20:39:40 +01:00
Nick Wellnhofer
02cc5c3609 parser: Add XML_PARSE_NO_XXE parser option 2024-01-05 20:39:40 +01:00
Nick Wellnhofer
12f0bb9478 parser: Synchronize more options 2024-01-05 20:39:40 +01:00
Nick Wellnhofer
3efbe916a1 parser: Mark 'token' member as unused in xmlParserCtxt 2024-01-05 20:39:40 +01:00
Nick Wellnhofer
b82fd81d06 parser: Rework xmlCtxtParseDocument
Make xmlCtxtParseDocument take a parser input which can be popped after
parsing.
2024-01-05 20:39:40 +01:00
Nick Wellnhofer
c2b3294f60 fuzz: Abort on invalid UTF-8
The parser should never generate invalid UTF-8 these days even in
recovery mode.
2024-01-04 21:20:51 +01:00
Michele Bianchi
df098e3bf6 Set LIBXML2_FOUND if it has been properly configured 2024-01-04 19:22:57 +00:00
Nick Wellnhofer
d7d300ba04 parser: Remove remnants of runtime debugging feature
Apparently, this feature was remove long ago.

Fixes #651.
2024-01-04 17:50:11 +01:00
Nick Wellnhofer
8c5848bdd5 parser: Make xmlParseContent more useful
This is an internal function which isn't really usable without some
hacks. See WebKit/Chromium trying to recreate the effects of
xmlDetectSAX2 manually, for example.

Make xmlParseContent perform late initialization and check whether the
content was fully parsed.

Also rename xmlDetectSAX2 and document why it's needed.
2024-01-04 17:45:03 +01:00
Nick Wellnhofer
65c65b6524 tests: Move away from global error handlers 2024-01-04 15:41:43 +01:00
Nick Wellnhofer
07c05546fa error: Make xmlFormatError public
This is a useful function to get a verbose error report.

Allows to remove duplicated code from runtest.c. Also reactivate check
for schema parser failures.
2024-01-04 15:41:43 +01:00
Nick Wellnhofer
d0eb5a7e54 parser: Remove xmlErrEncodingInt
Convert the last user to xmlFatalErr.
2024-01-04 15:28:57 +01:00
Nick Wellnhofer
f30b9b2331 fuzz: Add assertion in xmlCopyCharMultibyte
This is an internal function that should never receive out-of-range
codepoints.
2024-01-04 15:28:57 +01:00
Nick Wellnhofer
a7356dfecc parser: Clear invalid entity content
This was removed in earlier commits, but we really want to make sure
that entity content is syntactically valid.
2024-01-04 15:28:57 +01:00
Nick Wellnhofer
30d839776a fuzz: Disable catalogs
The catalogs API doesn't report OOM errors. It's basically impossible
to use it safely in its current form.
2024-01-04 15:18:14 +01:00
Nick Wellnhofer
ca5965d594 save: Report more malloc failures 2024-01-02 23:43:06 +01:00
Nick Wellnhofer
2c9cd0b68b fuzz: Abort on internal errors 2024-01-02 19:48:23 +01:00
Nick Wellnhofer
661ef93694 valid: Fix some error codes 2024-01-02 19:48:23 +01:00
Nick Wellnhofer
0821efc8ee encoding: Check whether encoding handlers support input/output
The "HTML" encoding handler doesn't support input which could lead to a
wrong error report.
2024-01-02 19:48:23 +01:00
Nick Wellnhofer
85f99023ae parser: Fix buffer size checks
Don't test size of remaining data. This causes false positives with
memory buffers.

Also impose XML_MAX_HUGE_LENGTH limit when parsing with XML_PARSE_HUGE.
2024-01-02 19:48:23 +01:00
Nick Wellnhofer
e8fb3d639f parser: Convert some "internal errors" to meaningful codes 2024-01-02 19:48:23 +01:00
Nick Wellnhofer
9912c36904 SAX2: Enforce size limit in xmlSAX2Text with XML_PARSE_HUGE 2024-01-02 19:48:23 +01:00
Nick Wellnhofer
5cb4b05c57 parser: Lower maximum entity nesting depth
Limit entity nesting depth to 20 or 40 with XML_PARSE_HUGE.

Change error code to XML_ERR_RESOURCE_LIMIT.
2024-01-02 19:48:23 +01:00
Nick Wellnhofer
a2cc7f5f04 parser: Set depth limit to 2048 with XML_PARSE_HUGE
Deeply nested documents can cause performance problems, so the nesting
depth should always be limited to a reasonable value.

Also remove the global xmlParserMaxDepth setting which isn't thread-safe
and seems unused.
2024-01-02 19:42:06 +01:00
Nick Wellnhofer
875bb08489 parser: Implement xmlCtxtSetOptions
Surprisingly, some options can only be enabled with xmlCtxtUseOptions
and it's impossible to unset them. Add a new API function
xmlCtxtSetOptions which sets or clears all options.

Finally document all parser options.

Make sure to synchronize option bits and struct members.
2024-01-02 19:42:06 +01:00
Nick Wellnhofer
33ec407a73 parser: Always prefer option members over bitmask
If an option has an extra member in xmlParserCtxt, it takes precedence
over the value from the options bitmask. Fix a few places where this was
ignored.
2024-01-02 17:58:53 +01:00
Nick Wellnhofer
22fd571f3c parser: Don't modify SAX2 handler if XML_PARSE_SAX1 is set
It's a bad idea to modify members of the SAX handler struct for option
state management. Ideally, ctxt->options should be the preferred source
of truth.
2024-01-02 16:42:23 +01:00
Nick Wellnhofer
37c6618be5 parser: Rework parsing of attribute and entity values
Don't use a separate function to handle "complex" attributes. Validate
UTF-8 byte sequences without decoding. This should improve performance
considerably when parsing multi-byte UTF-8 sequences.

Use a string buffer to avoid unnecessary allocations and copying when
expanding entities.

Normalize attribute values in a single pass while expanding entities.

Be more lenient in recovery mode.

If no entity substitution was requested, validate entities without
expanding. Fixes #596.

Also fixes #655.
2024-01-02 15:42:03 +01:00