1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-24 21:33:51 +03:00
Commit Graph

323 Commits

Author SHA1 Message Date
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
Nick Wellnhofer
1b6403583b schemas: Stop using xmlValidateNotationUse
Simplify symbol availability logic.
2024-06-16 18:47:12 +02:00
Nick Wellnhofer
b0fc67aa22 build: Remove --with-tree configuration option
This option would allow for a smaller, but mostly useless minimal build.
But it complicates the symbol availability logic in an insane way and
requires specialized tools like our custom C parser in doc/apibuild.py.

See #717.
2024-06-16 18:47:12 +02:00
Nick Wellnhofer
11cd18d879 valid: Check return value of xmlValidBuildAContentModel
Fixes return code in case of malloc failure.
2024-05-31 13:31:09 +02:00
Nick Wellnhofer
e75e878e02 doc: Update and fix documentation 2024-05-20 14:23:39 +02:00
Nick Wellnhofer
0651ad667c valid: Report malloc failure after xmlRegExecPushString 2024-05-13 13:08:14 +02:00
Nick Wellnhofer
9bce9dbb19 valid: Report malloc failure in xmlValidateOneElement 2024-03-26 14:30:57 +01:00
Nick Wellnhofer
577e2516d0 valid: Check for NULL node->name in xmlSnprintfElements
Unfortunately, we can have NULL element names if xmlSetTreeDoc fails.
2024-03-19 17:06:07 +01:00
Nick Wellnhofer
dc2a03d482 valid: Deprecate internal validation functions 2024-03-16 15:20:08 +01:00
Nick Wellnhofer
291a9d0f81 valid: Set document on dummmy element declaration 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
9033a27068 malloc-fail: Stop using xmlSplitQName2
This function doesn't report malloc failures.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
b38f8eae07 malloc-fail: Report in xmlAddAttributeDecl 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
3061b56a1e valid: Check for NULL text content in xmlValidateOneElement
Shouldn't occur in parsed documents but you can create text nodes with
NULL content through the API.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
af3d80b9a0 valid: Check for elem->name in xmlIsID
elem->name can be NULL is xmlNodeSetDoc failed.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
1233805dcb valid: Fix some return codes after errors 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
04c691f7ea valid: Eliminate xmlCtxtGetDtdElementDesc
Improves malloca failure reporting without parser context.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
ab345338a4 valid: Report malloc failure in legacy DTD serialization 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
264b283c27 valid: Fix hash removal in xmlRemoveRef
Don't create a NULL entry.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
802ad903f8 valid: Don't report errors with null context 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
f797cdabf5 valid: Remove id before updating attribute type 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
a3e11e3de1 valid: Fix id handling in xmlValidateDtd
Free id table before and after validation.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
c4e0db6a9e valid: Reset attribute in xmlFreeID 2024-03-15 19:47:08 +01:00
Nick Wellnhofer
bbbd7f7786 valid: Rework checks in xmlValidateOneElement
Don't check element for extra members and missing content.

Consolidate checks for unexpected elements.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
b23175d1d8 valid: Check element type in xmlIsID
Also rearrange code for readability.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
0ddd63dbab valid: Change error code to XML_ERR_ARGUMENT 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
d0d6174e81 valid: Rework xmlAddID 2024-03-15 19:47:07 +01:00
Nick Wellnhofer
9835ec2b97 valid: Fix xmlAddIDSafe in "streaming" mode
Make sure that IDs and attributes never reference each other in
streaming (XML reader) mode, even when attributes are copied from an
entity.

Also update lineno.

Fixes a short-lived use-after-free.
2024-02-13 12:05:21 +01:00
Nick Wellnhofer
2807df9a4a valid: Fix another use-after-free in xmlAddIDSafe
Short-lived regression.
2024-02-06 12:07:19 +01:00
Nick Wellnhofer
70da4c089c valid: Fix use-after-free in xmlAddIDSafe
Short-lived regression.
2024-02-04 14:33:19 +01:00
Nick Wellnhofer
cf8751942b valid: Deprecate old DTD serialization API 2024-02-04 14:33:19 +01:00
Nick Wellnhofer
fbe10a466f save: Move DTD serialization code to xmlsave.c 2024-02-04 14:33:19 +01:00
Nick Wellnhofer
661ef93694 valid: Fix some error codes 2024-01-02 19:48:23 +01:00
Nick Wellnhofer
d025cfbb4b parser: Always copy content from entity to target.
Make sure that references from IDs are updated.

Note that if there are IDs with the same value in a document, the last
one will now be returned. IDs should be unique, but maybe this should be
addressed.
2023-12-29 01:22:11 +01:00
Nick Wellnhofer
130436917c parser: Rename xmlErrParser to xmlCtxtErr 2023-12-21 15:02:24 +01:00
Nick Wellnhofer
54c70ed57f parser: Improve error handling
Introduce xmlCtxtSetErrorHandler allowing to set a structured error for
a parser context. There already was the "serror" SAX handler but this
always receives the parser context as argument.

Start to use xmlRaiseMemoryError.

Remove useless arguments from memory error functions. Rename
xmlErrMemory to xmlCtxtErrMemory.

Remove a few calls to xmlGenericError.

Remove support for runtime entity debugging.
2023-12-21 02:46:27 +01:00
Nick Wellnhofer
355fbe3ab7 valid: Fix handling of enumerations
Make xmlFreeEnumeration, xmlCopyEnumeration and xmlDumpEnumeration
non-recursive. Report malloc failure in xmlCopyEnumeration.
2023-12-16 15:10:15 +01:00
Nick Wellnhofer
61b4c42f38 valid: Report malloc failures
Fix many places where malloc failures aren't reported.
2023-12-11 22:13:06 +01:00
Nick Wellnhofer
e34a49b78e valid: Improve addition and deletion of IDs
Introduce a new API function xmlAddIDSafe that returns a separate error
code if a memory allocation fails.

Store a pointer to the ID struct in xmlAttr so attributes can be
freed without allocating memory. It's impossible to report malloc
failures in deallocation code.
2023-12-11 22:13:05 +01:00
Nick Wellnhofer
8c084ebdc7 doc: Make apibuild.py happy 2023-09-21 22:57:33 +02:00
Nick Wellnhofer
699299cae3 globals: Stop including globals.h 2023-09-20 22:07:40 +02:00
Nick Wellnhofer
4e1c13ebfd debug: Remove debugging code
This is barely useful these days and only clutters the code base.
2023-09-19 17:35:09 +02:00
Nick Wellnhofer
58de9d31da valid: Fix c1->parent pointer in xmlCopyDocElementContent
Fixes #572.
2023-08-03 12:00:55 +02:00
David Kilzer
cb1b8b8516 xmlValidatePopElement() can return invalid value (-1)
Covered by:  test/VC/ElementValid5

This only affects XML Reader API with LIBXML_REGEXP_ENABLED and
LIBXML_VALID_ENABLED turned on.

* result/VC/ElementValid5.rdr:
- Update result to add missing error message.

* python/tests/reader2.py:
* result/VC/ElementValid6.rdr:
* result/VC/ElementValid7.rdr:
* result/valid/781333.xml.err.rdr:
- Update result to fix grammar issue.

* valid.c:
(xmlValidatePopElement):
- Check return value of xmlRegExecPushString() to handle -1, and
  assign 'ret = 0;' to return 0 from xmlValidatePopElement().
  This change affects xmlTextReaderValidatePop() from
  xmlreader.c.
- Fix grammar of error message by changing 'child' to
  'children'.
2023-04-10 13:21:53 -07:00
Nick Wellnhofer
08f9d319eb valid: Make xmlValidateElement non-recursive
Fixes call stack overflows when validating deeply nested documents.

Found by OSS-Fuzz.
2023-03-16 17:01:05 +01:00
Nick Wellnhofer
a57a7549fa valid: Allow xmlFreeValidCtxt(NULL) 2023-03-12 16:06:19 +01:00
Nick Wellnhofer
9fa1b228a5 malloc-fail: Fix memory leak in xmlGetDtdElementDesc2
Found with libFuzzer, see #344.
2023-02-17 17:16:51 +01:00