1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2026-01-26 21:41:34 +03:00
Commit Graph

1410 Commits

Author SHA1 Message Date
Nick Wellnhofer
18bbdb5117 dict: Rework reference counting
Use C11 atomics if available. Otherwise, fall back to pthread mutex
inlined in xmlDict struct or Win32 atomics.

This should fix lock contention reported in #970.
2025-08-16 14:37:14 +02:00
Nick Wellnhofer
c4b278ecd3 valid: Undeprecate xmlAdd*Decl
Fixes #969.
2025-08-11 13:44:56 +02:00
Nick Wellnhofer
3b96ec75ab doc: Document deprecated default SAX handler globals 2025-08-02 14:12:17 +02:00
Nick Wellnhofer
8436916097 doc: Add another warning to XML_PARSE_DTDVALID
While most parts of libxml2, including the parser, are still vulnerable
to such attacks, it is unlikely that DTD validation will ever be fixed.
2025-07-31 15:20:20 +02:00
Nick Wellnhofer
ab4a7f3011 doc: Document deprecated xmlBuffer members 2025-07-31 15:20:20 +02:00
Nick Wellnhofer
af464de1f3 io: Deprecate xmlOutputBuffer members 2025-07-31 15:20:20 +02:00
Nick Wellnhofer
6c0188549b io: Deprecate xmlParserInputBuffer members 2025-07-31 15:20:20 +02:00
Nick Wellnhofer
8689523ad9 parser: Implement xmlCtxtGetInputWindow
See #762.
2025-07-31 15:20:20 +02:00
Nick Wellnhofer
469c847f4d parser: Split out xmlParserInputGetWindow 2025-07-31 14:23:23 +02:00
Nick Wellnhofer
8aaa53d712 parser: Implement xmlCtxtGetInputPosition
See #762.
2025-07-31 14:23:23 +02:00
Nick Wellnhofer
144ed959a5 parser: Move xmlSaturatedAdd to private header 2025-07-31 14:23:23 +02:00
Nick Wellnhofer
a7fc9e1add parser: Add more parser context accessors
The only thing remaining is access to parser input, see #762.
2025-07-31 14:23:23 +02:00
Nick Wellnhofer
a2562b9d8a doc: Improve documentation of error levels 2025-07-31 14:23:23 +02:00
Nick Wellnhofer
7a41b18c62 parser: Remove xmlHaltParser
Always halt the parser on resource limit and entity loop errors and
remove the remaining calls which seem unnecessary.
2025-07-31 14:23:23 +02:00
Nick Wellnhofer
c5e7ff09b2 tree: More xmlNodeParseContent cleanup
- Rename to xmlNodeParseAttValue
- Rework argument types
- Remove wrapper function
2025-07-31 14:23:23 +02:00
Nick Wellnhofer
6340f39284 doc: Document HTML type aliases 2025-07-09 15:19:46 +02:00
Nick Wellnhofer
c7a9ef1d66 doc: Document struct typedefs
Unfortunately, Doxygen's TYPDEF_HIDES_STRUCT option is too broken.
Document struct typedefs to make autolinks work.
2025-07-04 16:47:42 +02:00
Nick Wellnhofer
9553695d17 relaxng: Make xmlRelaxNGDump depend on debug option 2025-06-30 16:23:54 +02:00
Daniel P. Berrangé
ac5fcb0e34 relaxng: ensure thread safe global initialization
Relying on a plain integer flag, with no synchronization primitives does
not give thread-safe initialization. All reads & writes of the
xmlSchemaTypesInitialized flag need to be protected by a mutex to ensure
suitable memory barriers & thus correct ordering wrt any speculative
execution.

A separate internal initializer tied to xmlParserInit is used to create
the mutex used for synchronization, similarly to how catalog.c works.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-06-26 17:46:19 +01:00
Daniel P. Berrangé
80798c406c xmlschemastypes: ensure thread safe global initialization
Relying on a plain integer flag, with no synchronization primitives does
not give thread-safe initialization. All reads & writes of the
xmlSchemaTypesInitialized flag need to be protected by a mutex to ensure
suitable memory barriers & thus correct ordering wrt any speculative
execution.

A separate internal initializer tied to xmlParserInit is used to create
the mutex used for synchronization, similarly to how catalog.c works.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2025-06-26 17:46:01 +01: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
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
e7802738c6 parser: Don't load external content if only XML_SKIP_IDS is set
At some point, the `loadsubset` member was augmented to also control
handling of ID attributes in addition to loading of external DTDs. These
two features are unrelated and shouldn't have been mixed. This mistake
was probably inspired by the misnamed XML_DETECT_IDS flag. As a side
effect, setting XML_SKIP_IDS always enabled loading of external DTDs and
parameter entities.

This change makes it possible to ignore IDs without loading external
content. This is a deliberate API change that improves security and is
unlikely to affect users.

This also makes sure that the new XML_PARSE_SKIP_IDS option doesn't
enable unsafe behavior.
2025-06-22 15:18:43 +02:00
Nick Wellnhofer
7e3818424a include: s/char const/const char/ 2025-06-22 14:31:26 +02:00
Nick Wellnhofer
19139061fb include: Define XMLPUBVAR directly
Using an intermediate macro confuses newer Doxygen versions for some
reason.
2025-06-22 14:31:26 +02:00
Nick Wellnhofer
a4d25b3d93 doc: Small fixes 2025-06-22 14:31:26 +02:00
Michael Mann
cf4f967266 Add XML_PARSE_SKIP_IDS to replace XML_SKIP_IDS
Mark loadset member as deprecated

Fixes #873
2025-06-22 08:03:34 -04:00
Nick Wellnhofer
2963a0f13a tree: Undeprecate some members used by libxslt 2025-06-20 21:41:24 +02:00
Nick Wellnhofer
7e08d93c94 doc: Improve documentation of tree data types 2025-06-08 14:22:32 +02:00
Nick Wellnhofer
2b6b3945f2 Revert "SAX1: Align handling of default attributes with SAX2"
This reverts commit db65b2fc51.

This didn't check for duplicate default attributes.
2025-06-03 16:21:56 +02:00
Nick Wellnhofer
5e7c72cd5c doc: Misc fixes 2025-06-03 01:27:12 +02:00
Nick Wellnhofer
5f8e537d0a doc: Misc fixes to xpointer 2025-06-03 00:59:00 +02:00
Nick Wellnhofer
0ab5d7c557 entities: Deprecate internal DTD-related functions 2025-06-03 00:13:26 +02:00
Nick Wellnhofer
347c2b2ec7 valid: Deprecate a few functions and xmllint --insert 2025-06-02 23:54:28 +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
6e33d136e1 error: Fix initGenericErrorDefaultFunc compatibility macro again
Now it really should work as before.
2025-05-28 14:57:37 +02:00
Nick Wellnhofer
30cf6d0980 parser: Add XML_INPUT_USE_SYS_CATALOG
Also clean up catalog resolution and add error handling using the
global error.

Don't try to look up the resolved URI a second time.

Add some comments. Fix documentation.
2025-05-26 16:51:59 +02:00
Nick Wellnhofer
4dc44c83ab parser: Rework entity boundary check for element content
Only use depth of input stack. This makes the input ID unused
internally.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
db65b2fc51 SAX1: Align handling of default attributes with SAX2
The SAX1 parser is legacy code, but it seems more maintainable to align
it with SAX2.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
2f3655c9c3 parser: Pop PEs that start markup declarations explicitly
We currently only handle "Validity constraint: Proper Declaration/PE
Nesting", but we must detect "Well-formedness constraint: PE Between
Declarations" separately:

> The replacement text of a parameter entity reference in a DeclSep must
> match the production extSubsetDecl.

PEs in DeclSeps are PEs that start with a full markup declaration (or
another PE). These are handled in xmParse{Internal|External}Subset. We
set a flag on these PEs and don't close them implicitly in
xmlSkipBlankCharsPE. This will make unterminated declarations in such
PEs cause a parser error. The PEs are closed explicitly in
xmParse{Internal|External}Subset, the only location where they are
allowed to end.
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
fca0860d6c tree: Deprecate public struct members related to DTDs
Let's deprecate these members for now. If these are really used, they
can be undeprecated later.
2025-05-25 14:26:30 +02:00
Nick Wellnhofer
7c9b55356d doc: Document unused error domains 2025-05-19 20:07:54 +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
210f5a3746 chvalid: Mark functions as deprecated 2025-05-16 23:27:51 +02:00
Nick Wellnhofer
954aae907d doc: Improve regexp documentation 2025-05-16 21:13:17 +02:00
Nick Wellnhofer
c5b45fbc07 doc: Misc fixes 2025-05-16 19:04:20 +02:00
Nick Wellnhofer
c4926b19d3 codegen: Merge xmlunicode.c into xmlregexp.c
Include generated parts.

Generate xmlChRangeGroups instead of functions for Unicode blocks.
2025-05-16 19:04:20 +02:00
Nick Wellnhofer
4cb767e96e codegen: Only generate tables for character ranges
The rest can be easily maintained manually.
2025-05-16 19:04:20 +02:00
Nick Wellnhofer
6f4b452742 parser: Stop using ctxt->linenumbers
I think this was used to avoid setting the `line` member before it was
added (20+ years ago).
2025-05-16 18:03:12 +02:00