1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-10-23 01:52:48 +03:00
Commit Graph

368 Commits

Author SHA1 Message Date
Nick Wellnhofer
4d69f91b25 valid: Make validation fail if warnings cause OOM error
Make xmlErrValidWarning return -1 on malloc failures.
2025-07-14 17:24:54 +02:00
Nick Wellnhofer
24628f2590 valid: Don't store attribute defaults in dictionary
In general, we should only use dicts for names and not values.
2025-06-23 22:59:31 +02:00
Nick Wellnhofer
600742f0f1 valid: Unconst local variable in xmlValidateElement 2025-06-23 22:59:31 +02:00
Nick Wellnhofer
7c91385040 parser: Remove unnecessary dict checks when freeing strings
The following strings are never allocated from a dict:

- xmlParserCtxt.version
- xmlParserCtxt.encoding
- xmlParserCtxt.extSubURI
- xmlParserCtxt.extSubSystem
- xmlDoc.version
- xmlDoc.encoding
- xmlDoc.URL
- xmlDTD.ExternalID
- xmlDTD.SystemID
- xmlID.value

Also make the struct members point to non-const chars to avoid casts
when freeing.
2025-06-23 22:59:31 +02:00
Nick Wellnhofer
607708b35f valid: Don't store ID values in document's dictionary
ID values are unique. There's some potential for them to be reused as
references, but storing them in the dictionary can make the dictionary
grow in proportion to the document.

Users like lxml replace the `ids` hash table to avoid this. It seems
like a good idea to stop using the dictionary for ID values.
2025-06-23 22:59:19 +02:00
Nick Wellnhofer
347c2b2ec7 valid: Deprecate a few functions and xmllint --insert 2025-06-02 23:54:28 +02:00
Nick Wellnhofer
ac6ae39192 valid: Readd more argument checks in xmlAddElementDecl
Fix crashes with API fuzzer.
2025-06-02 14:33:15 +02:00
Nick Wellnhofer
7bd8d1d9cc doc: Prefix autolinks with '#'
Use `#func` instead of `func()` to ignore parameters and make all
autolinks work.
2025-05-28 16:01:52 +02:00
Nick Wellnhofer
77c583e0f7 valid: Readd argument check in xmlAddElementDecl
Fix crashes with API fuzzer.
2025-05-27 19:55:36 +02:00
Nick Wellnhofer
6f8ac9538c valid: Don't use element namespace for attributes
This makes no sense. Unprefixed attributes never have a namespace.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
5ec83f7741 valid: Remove duplicate #FIXED check for namespaces
Unlike the comment indicates, this is already checked.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
7c10fff265 valid: Don't validate twice in xmlAddAttributeDecl
This should only be done in xmlValidateAttributeDecl.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
2a60ca06c0 valid: Don't check enum values
Rely on the parser to pass valid arguments.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
fc1cabc822 valid: Also raise duplicate ID error without validation support
Whether an error is raised should not depend on config options.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
dd1961e0d8 valid: Skip more validity checks if not validating 2025-05-25 14:26:30 +02:00
Nick Wellnhofer
6c2bd9758f valid: Don't validate unused default attributes
See erratum E9 of XML 1.0 Second Edition.

See #120.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
7008740a96 parser: Consolidate scanning of XML Names
Use new productions by default.

Fixes #194.
Fixes #364.
See #707.
2025-05-19 19:58:33 +02:00
Nick Wellnhofer
c5b45fbc07 doc: Misc fixes 2025-05-16 19:04:20 +02:00
Nick Wellnhofer
adfbeb7e08 doc: Stop using *Ptr typedefs in documentation 2025-05-16 18:03:12 +02:00
Nick Wellnhofer
a40f36e7f2 include: Stop using *Ptr typedefs in public headers 2025-05-16 18:03:12 +02:00
Nick Wellnhofer
9bbffec568 doc: Move brief to top, params to bottom of doc comments 2025-05-06 19:51:38 +02:00
Nick Wellnhofer
81ac2e27fd doc: Misc fixes to valid docs 2025-05-06 19:51:38 +02:00
Nick Wellnhofer
2c150e62f5 doc: Formatting fixes 2025-05-02 20:21:39 +02:00
Nick Wellnhofer
cb1635a642 doc: Use @since command 2025-05-02 19:05:25 +02:00
Nick Wellnhofer
e78e05c990 doc: Fix autolinks to functions
Unfortunately, autolinks in .c files aren't converted by Doxygen for
some reason.
2025-05-02 17:45:31 +02:00
Nick Wellnhofer
f7c412874b doc: Remove more comment block headers 2025-05-02 17:41:26 +02:00
Nick Wellnhofer
e525564f65 doc: Remove empty lines at start of block
These lines were left over after automatic conversion.
2025-05-02 11:42:05 +02:00
Nick Wellnhofer
e549622bc5 doc: Convert documentation to Doxygen
Automated conversion based on a few regexes.
2025-05-01 23:23:42 +02:00
Nick Wellnhofer
69879da88f doc: Remove email addresses from documentation
Also remove authorship information from generated files, hash.c and
globals.c which were rewritten.
2025-05-01 23:23:42 +02:00
Nick Wellnhofer
61890e399d doc: Prepare for conversion to Doxygen
Fix many params in internal functions (not really necessary but Doxygen
warns about that in XML mode).

Fix formatting in a few corner cases that automatic conversion can't
handle.

Rearrange some DOC_DISABLE blocks.
2025-05-01 23:23:42 +02:00
Nick Wellnhofer
6896f478d4 Revert "valid: Remove duplicate error messages when streaming"
This reverts commit cd220b93d8.

This commit broke the xmstarlet tests.
2025-04-18 17:24:45 +02:00
Nick Wellnhofer
63dfcca670 fuzz: Reduce initial array size 2025-02-20 12:22:12 +01:00
Nick Wellnhofer
8c8753ad52 [CVE-2025-24928] Fix stack-buffer-overflow in xmlSnprintfElements
Fixes #847.
2025-02-18 15:07:51 +01:00
Zak Ridouh
b466e70ae5 Fix early return in vstateVPush in valid.c
While looking over the code in the fallback method for `vstateVPush` in
valid.c when `LIBXML_REGEXP_ENABLED` is not defined, I noticed that
there is an ungated `return(-1)` after attempting to allocate memory.

I believe this should be inside a check, for if the malloc fails.
2025-02-05 14:11:04 -08:00
Nick Wellnhofer
71c37a565d malloc-fail: Fix memory leak in xmlValidateElementContent 2024-12-30 11:42:40 +01:00
Nick Wellnhofer
cd220b93d8 valid: Remove duplicate error messages when streaming 2024-12-28 11:55:24 +01:00
Nick Wellnhofer
bd2a16489f valid: Fix build --without-regexps 2024-12-28 11:55:24 +01:00
Nick Wellnhofer
2e3a91a766 doc: Fix documentation 2024-12-26 21:05:39 +01:00
Nick Wellnhofer
0d4a17af49 valid: Fix and check return value of nodeVPush 2024-12-21 19:41:44 +01:00
Nick Wellnhofer
178b11219c valid: Check reallocations for overflow 2024-12-21 19:37:38 +01:00
Nick Wellnhofer
5204c872bb valid: Reset context before validating
Reset last error and "stopped" flag. Otherwise new errors could be
ignored.
2024-11-26 14:30:54 +01:00
Nick Wellnhofer
4d1f35b0a9 valid: Deprecate more internal functions 2024-11-19 00:03:37 +01:00
Nick Wellnhofer
5a51f08517 valid: Implement xmlCtxtValidateDocument
This allows to use the error handler or resource loader of a parser
context.
2024-11-19 00:03:37 +01:00
Nick Wellnhofer
1e1731a43d valid: Add NULL check in xmlCtxtValidateDtd 2024-11-17 13:20:06 +01:00
Nick Wellnhofer
7f8c436c75 parser: Implement xmlCtxtParseDtd and xmlCtxtValidateDtd
This allows to use the context's error handler, options and other
settings.

Fixes #808.
2024-11-15 16:30:52 +01:00
Nick Wellnhofer
0c56eb8215 tree: Restore return value of xmlNodeListGetString with NULL list
When passing a NULL list to xmlNodeListGetString or
xmlNodeListGetRawString, return NULL instead of "" to match the old
behavior.

Fixes #783.
2024-08-12 21:38:50 +02:00
Nick Wellnhofer
6be79014d7 Remove unused code 2024-07-15 16:33:38 +02:00
Nick Wellnhofer
842a044831 valid: Restore ID lookup
Revert a change from d025cfbb and don't overwrite ID table entries, so
that the first attribute will be returned if there are duplicate IDs.

This requires two other changes:

- Attributes in entity content are never added to the ID table. This
  seems reasonable.

- Remove the optimization to skip ID lookup when copying and the target
  document has an empty ID table. This also seems more correct since the
  document could have ID declarations nevertheless or we could be
  copying xml:ids into the document for the first time.

Fixes #757.
2024-07-03 11:46:06 +02:00
Rosen Penev
2def7b4b28 clang-tidy: move assignments out of if
Found with bugprone-assignment-in-if-condition

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-06-20 21:11:44 -07:00
Rosen Penev
217e9b7af2 clang-tidy: don't return in void functions
Found with readability-redundant-control-flow

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2024-06-20 20:37:34 +00:00