tree.c


Log

Author Commit Date CI Message
Nick Wellnhofer 6a6a46f0 2025-05-28T16:02:41 doc: Fix autolink errors Fix links, remove links to internal functions.
Nick Wellnhofer 7bd8d1d9 2025-05-28T15:53:38 doc: Prefix autolinks with '#' Use `#func` instead of `func()` to ignore parameters and make all autolinks work.
Nick Wellnhofer ad346c9a 2025-05-27T12:53:17 tree: Fix integer overflow in xmlBuildQName This issue affects memory safety and might receive a CVE ID later. Fixes #926.
Nick Wellnhofer 7008740a 2025-05-18T01:52:38 parser: Consolidate scanning of XML Names Use new productions by default. Fixes #194. Fixes #364. See #707.
Nick Wellnhofer c5b45fbc 2025-05-16T16:54:09 doc: Misc fixes
Nick Wellnhofer adfbeb7e 2025-05-14T04:58:21 doc: Stop using *Ptr typedefs in documentation
Nick Wellnhofer a40f36e7 2025-05-14T04:04:28 include: Stop using *Ptr typedefs in public headers
Nick Wellnhofer 777e2adf 2025-05-09T23:53:03 io: Consolidate escaping code Use generated table approach of xmlSerializeText for xmlEscapeText. Move most code to xmlIO.c.
Nick Wellnhofer dad11630 2025-05-09T22:05:38 entities: Always replace invalid chars when escaping The previous refactor painstakingly recreated the different behavior of separate functions that were merged. It makes Optimize IS_CHAR check for non-ASCII chars.
Nick Wellnhofer 971038e5 2025-05-09T20:26:33 html: Call lower-level escaping functions Removes the need to pass a document around.
Nick Wellnhofer 63535d39 2025-05-09T20:13:43 tree: Make xmlNodeListGetStringInternal work with escape flags
Nick Wellnhofer 442c1903 2025-05-09T18:52:36 doc: Fix some damage from automated conversions Add some newlines, fix returns.
Nick Wellnhofer 98a61c9d 2025-05-09T16:48:09 doc: Fix briefs in tree docs
Nick Wellnhofer 9aaa52fe 2025-05-08T22:49:20 tree: Make xmlNodeAddContent work with attributes
Nick Wellnhofer 9bbffec5 2025-05-06T17:42:46 doc: Move brief to top, params to bottom of doc comments
Nick Wellnhofer e6cfd049 2025-05-04T14:52:42 doc: Misc fixes to tree docs
Nick Wellnhofer cb1635a6 2025-05-02T19:05:25 doc: Use @since command
Nick Wellnhofer e78e05c9 2025-05-02T17:32:51 doc: Fix autolinks to functions Unfortunately, autolinks in .c files aren't converted by Doxygen for some reason.
Nick Wellnhofer f7c41287 2025-05-02T15:57:17 doc: Remove more comment block headers
Nick Wellnhofer e525564f 2025-05-01T19:20:06 doc: Remove empty lines at start of block These lines were left over after automatic conversion.
Nick Wellnhofer e549622b 2025-04-28T15:11:24 doc: Convert documentation to Doxygen Automated conversion based on a few regexes.
Nick Wellnhofer 69879da8 2025-04-28T14:04:30 doc: Remove email addresses from documentation Also remove authorship information from generated files, hash.c and globals.c which were rewritten.
Nick Wellnhofer 61890e39 2025-04-27T21:50:15 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.
Nick Wellnhofer dd4c0f62 2025-03-18T11:11:20 tree: Fix xmlTextMerge with NULL args Restore pre-2.13 behavior. Fixes #875.
Nick Wellnhofer 6ab430ca 2025-02-22T21:17:42 Remove unnecessary #includes
Nick Wellnhofer 9c16a153 2025-02-13T18:41:33 Revert "include: Make most IS_* macros private" This reverts commit 84a6c82ff83d04963d6e1c5cd18ded68ea02d99f.
Grzegorz Szymaszek 9d7bbf19 2025-01-23T14:36:33 tree: Fix variable name in xmlAddChild documentation
Nick Wellnhofer ca819160 2025-01-03T20:50:08 include: Use intptr_t to cast between pointers and ints
Nick Wellnhofer 84a6c82f 2024-12-19T20:59:10 include: Make most IS_* macros private Macros like IS_DIGIT or IS_LETTER severely pollute the C namespace.
Nick Wellnhofer 2042090b 2024-12-15T22:32:12 tree: Check reallocations for overflow
Nick Wellnhofer 0c56eb82 2024-08-12T21:38:50 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.
Nick Wellnhofer 5d36664f 2024-07-16T00:35:53 memory: Deprecate xmlGcMemSetup
Nick Wellnhofer 888f70c7 2024-07-07T11:35:54 buf: Move xmlBuffer code to buf.c
Nick Wellnhofer a221cd78 2024-07-07T03:01:51 buf: Rework xmlBuf code Always use what the old implementation called the "IO" allocation scheme, allowing to move the content pointer past the initial allocation. This is inexpensive and allows efficient shrinking. Optimize xmlBufGrow, reusing shrunken memory as much as possible. Simplify xmlBufAdd. Make xmlBufBackToBuffer return an error on overflow. Make "size" exclude the terminating NULL byte. Always provide an initial size. Reintroduce static buffers. Remove xmlBufResize and several other functions.
Nick Wellnhofer 8d160626 2024-07-12T02:01:06 entities: Rework text escaping
Nick Wellnhofer de3221b1 2024-07-06T15:23:30 fuzz: Adjust for xmlNodeParseContent changes xmlStringGetNodeList returns NULL again for empty strings.
Nick Wellnhofer 944cc23c 2024-07-03T15:54:32 tree: Fix handling of empty strings in xmlNodeParseContent We shouldn't create an empty text node to match the old behavior. Fixes #759.
Nick Wellnhofer 842a0448 2024-07-03T11:46:06 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.
Nick Wellnhofer f505dcae 2024-06-26T14:11:34 tree: Remove underscores from xmlRegisterCallbacks
Nick Wellnhofer b0fc67aa 2024-06-15T22:53:55 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.
Nick Wellnhofer 2f128096 2024-06-14T16:44:09 tree: Fix freeing entities via xmlFreeNode Call xmlFreeEntity to free all entity members. Fixes #731.
Nick Wellnhofer 5198de4b 2024-05-31T13:42:08 fuzz: Make allocation in xmlBuildQName more likely Limit size of static buffer in fuzzing mode.
Nick Wellnhofer e75e878e 2024-05-20T13:58:22 doc: Update and fix documentation
Nick Wellnhofer b8597f46 2024-04-30T15:58:01 tree: Handle predefined entities in xmlBufGetEntityRefContent It's possible to create references to predefined entities using the tree API. This edge case was exposed by making predefined entities const in commit 63ce5f9a.
Nick Wellnhofer 619e2808 2024-04-30T15:53:08 tree: Don't call xmlNewCharRef in xmlNodeParseContent xmlNewCharRef also tries to handle strings like '&name;' but in xmlNodeParseContentInternal, we really want to use the possibly invalid name without modification. Otherwise, content like '&"' could create a reference to a predefined entity.
Nick Wellnhofer 5e80f438 2024-04-28T17:33:19 tree: Deprecate xmlRegisterNodeDefault This rarely used feature should be phased out.
Nick Wellnhofer 88169bfd 2024-04-28T17:54:36 tree: Deprecate xmlSetCompressMode
Niels Dossche 6053f1ff 2023-11-02T13:57:54 Remove redundant size check The condition size > UINT_MAX - 10 is already checked earlier, so the check is always false.
Nick Wellnhofer fbea03f3 2024-04-19T15:22:30 tree: Remove another redundant check in xmlDOMWrapCloneNode The node type was already checked earlier.
Niels Dossche 1a865567 2023-11-02T14:07:00 Remove redundant NULL check on cur This variable is already NULL checked in the previous if condition.
Niels Dossche 6fadd798 2023-11-02T14:05:31 Remove always-false check old == cur This case is already checked at the start of the function. There it returns NULL, which seems more correct.
Niels Dossche 27665200 2023-11-02T13:59:54 Remove redundant NULL check on cur cur = node, and node cannot be NULL as it is checked at the start of the function.
Nick Wellnhofer a0341ac8 2024-04-18T12:08:30 tree: Don't return empty localname in xmlSplitQName{2,3} Match the behavior of xmlSplitQName and xmlSplitQName4.
Nick Wellnhofer 5c553325 2024-03-29T13:45:19 Revert "tree: Only allow elements in xmlDocSetRootElement" This reverts commit 4b698dbaec9bc6775fc8341ef8a3f0d8321f8548. lxml assumes that xmlDocSetRootElement works with non-elements.
Nick Wellnhofer 7c5daa37 2024-03-29T14:35:07 tree: Ignore namespace with NULL href in xmlSearchNs Some users set href to NULL to unset a namespace without deleting it. Also change the duplicate check in xmlNewNs which must agree with xmlSearchNs. Short-lived regression from f960c60d.
Nick Wellnhofer f43197fc 2024-03-29T11:16:45 tree: Don't coalesce text nodes in xmlAdd{Prev,Next}Sibling Commit 9e1c72da from 2001 introduced a bug where xmlAddPrevSibling and xmlAddNextSibling would only try to merge text nodes with one of its new siblings. Commit 4ccd3eb8 fixed this bug but unfortunately, lxml and possibly other downstream code depend on text nodes not being merged. To avoid breaking downstream code while still having somewhat consistent API behavior, it's probably best to make these functions never coalesce text nodes.
Nick Wellnhofer 2a713a80 2024-03-28T15:09:46 tree: Document behavior if xmlSetTreeDoc fails
Nick Wellnhofer f1e9c7bd 2024-03-28T14:54:18 tree: Optimize xmlInsertNode Relink the node directly without calling xmlUnlinkNodeInternal.
Nick Wellnhofer ea0ee365 2024-03-28T12:38:43 tree: Align xmlAddChild with other node insertion functions Make xmlAddChild unlink the child before insertion. Originally, linked children would most likely cause tree corruption. The first fix disallowed linked nodes, but there are cases where insertion of such nodes could succeed. Don't abort if the node is already a child of parent. In this case, the node will be moved to the end of the child list.
Nick Wellnhofer e5cdb23f 2024-03-28T14:09:10 tree: Introduce xmlUnlinkNodeInternal xmlUnlinkNode also removes references to DTD nodes which shouldn't be done when moving nodes within a document. Introduce a new function xmlUnlinkNodeInternal which only unlinks a node from the tree. Remove references to DTD nodes in xmlNodeSetDoc. Note that moving element and attribute declarations to another document will still leave references in the source document.
Nick Wellnhofer 23a81841 2024-03-25T20:51:14 tree: Work on documentation
Nick Wellnhofer ad9a5637 2024-03-22T19:37:12 tree: Fix uninitialized value in xmlSearchNsSafe Short-lived regression.
Nick Wellnhofer 7b316c11 2024-03-22T12:15:23 tree: Fix uninitialized value in xmlSearchNsByHrefSafe Short-lived regression.
Nick Wellnhofer 3f05508a 2024-03-18T14:14:00 tree: Report malloc failures in attribute setters
Nick Wellnhofer 6a49bb77 2024-03-17T17:16:55 tree: Introduce xmlSearchNsSafe After the failed experiment with a static XML namespace, introduce versions of xmlSearchNs that report malloc failures. Optimize the no-document case by only adding the XML namespace declaration if it wasn't found in an ancestor.
Nick Wellnhofer 047ea3ec 2024-03-17T16:23:31 Revert "tree: Allocate XML namespace statically" This reverts commit 2840e33c5e4b51589a0b96e8102638eeaea6df72.
Nick Wellnhofer 2469d5d0 2024-03-15T02:55:11 tree: Tighten source doc check in xmlDOMWrapAdoptNode sourceDoc must match even if node->doc is NULL.
Nick Wellnhofer 37556eb3 2024-03-14T16:32:58 tree: Check destParent->doc in xmlDOMWrapCloneNode The document must match destDoc to avoid tree corruption.
Nick Wellnhofer 7c48c01b 2024-03-13T12:42:43 tree: Switch to xmlNodeSetDoc in xmlDOMWrapAdoptNode Report malloc failures. Also fixes an issue where xmlDOMWrapAdoptAttr would descend into entity references.
Nick Wellnhofer be2c26fb 2024-03-13T12:15:30 tree: Fix tree iteration in xmlDOMWrapRemoveNode We didn't descend into elements having attributes.
Nick Wellnhofer 4a90ce08 2024-03-12T22:30:43 tree: Don't abort early if malloc fails in DOM functions If malloc fails halfway through updating a subtree, we must process the rest of the tree to avoid tree corruption.
Nick Wellnhofer ad019ba1 2024-03-12T19:50:45 tree: Fix reallocation in xmlDOMWrapNSNormAddNsMapItem2
Nick Wellnhofer e321eba0 2024-03-12T17:42:28 tree: Set parent->last early in xmlDOMWrapCloneNode Avoids a corrupted tree in error case.
Nick Wellnhofer 84e6dc9e 2024-03-12T17:41:30 tree: Declare namespace on clone in xmlDOMWrapCloneNode The new namespace must be declared on the cloned node, not the source node.
Nick Wellnhofer 09905670 2024-03-12T17:40:30 tree: Don't free linked DOM namespaces in error case
Nick Wellnhofer 27f07f10 2024-03-12T16:49:10 tree: Report malloc failure in xmlDOMWrapCloneNode Also don't store text content in dictionaries.
Nick Wellnhofer 8d04f0ee 2024-03-11T20:44:47 tree: Refactor text node updates
Nick Wellnhofer 4ccd3eb8 2024-03-11T19:43:56 tree: Refactor node insertion Also fixes a text coalescing bug.
Nick Wellnhofer 9f049afa 2024-03-11T15:57:14 tree: Refactor element creation and parsing of attribute values Replace xmlStringGetNodeList and xmlStringLenGetNodeList with xmlNodeParseContentInternal which also updates an optional parent node. Don't look up entities a second time via xmlNewReference.
Nick Wellnhofer 9991fae4 2024-03-05T16:16:31 tree: Simplify xmlNodeGetContent, xmlBufGetNodeContent Factor out xmlBufGetEntityRefContent and xmlBufGetChildContent. Also allow entity declarations. Optimize single text children. Ignore missing or recursive entities silently. Prefer xmlNodeGetContent over xmlNodeListGetString. Check for entity cycles in xmlBufGetNodeContent. Use children pointer of entity reference nodes if available to look up entities.
Nick Wellnhofer 05adfbf8 2024-03-11T13:42:15 buf: Don't use default buffer size for small strings Detaching strings from a buffer with a default size of 4096 can waste a lot of memory.
Nick Wellnhofer e3342f73 2024-03-07T17:47:06 tree: Work on documentation
Nick Wellnhofer 8677f547 2024-03-05T03:24:45 malloc-fail: Fix erroneous report in xmlNodeGetBaseSafe
Nick Wellnhofer 9b3750c6 2024-03-04T03:49:23 malloc-fail: Avoid use-after-free in xmlAddChild Returning NULL doesn't signal that the node was freed.
Nick Wellnhofer 702f2e46 2024-03-04T01:39:34 malloc-fail: Fix memory leak in xmlNewNodeEatName
Nick Wellnhofer b043d959 2024-03-08T12:40:12 tree: Check return value of xmlNodeAddContent
Nick Wellnhofer 18ebdacf 2024-03-07T13:02:46 tree: Fix error return in xmlGetPropNodeValueInternal
Nick Wellnhofer e4e90961 2024-03-07T13:00:14 tree: Prefer xmlGetPropNodeInternal over xmlHasNsProp xmlHasNsProp can cause unreported malloc failures when looking up default attributes. Switch to xmlGetPropNodeInternal when moving attributes. We don't care about default attributes in this case.
Nick Wellnhofer 7d9ffd40 2024-03-06T19:44:00 tree: Report malloc failure in xmlAddNextSibling
Nick Wellnhofer bc7ab5a2 2024-03-02T18:59:51 tree: Rewrite xmlSetTreeDoc Report malloc failures. Fix when called directly on attribute node. Clear 'content' and 'last' and look up new entity for entity reference nodes.
Nick Wellnhofer 2ba690a7 2024-03-05T16:34:22 tree: Remove more unused node types
Nick Wellnhofer fc9a2ca0 2024-03-06T16:02:24 tree: Report more malloc failures
Nick Wellnhofer 536aa2cd 2024-03-04T16:55:32 tree: Fix adding ids in xmlNewPropInternal Don't try to add ids to NULL document. Report malloc failure from xmlIsID.
Nick Wellnhofer d0d6174e 2024-02-29T19:38:29 valid: Rework xmlAddID
Nick Wellnhofer d57c57ed 2024-03-05T14:53:35 tree: Improve argument check in xmlTextConcat
Nick Wellnhofer 16c29557 2024-03-05T14:52:34 tree: Remove unused node types
Nick Wellnhofer f960c60d 2024-03-05T03:25:16 tree: Make namespace comparison more consistent The API allows NULL namespace URIs, so we should match them consistently. Simply use xmlStrEqual which already takes NULL strings into account.
Nick Wellnhofer d1cc6f7d 2024-03-05T04:34:59 tree: Don't allow NULL name in xmlSetNsProp
Nick Wellnhofer 2840e33c 2024-03-04T07:34:25 tree: Allocate XML namespace statically
Nick Wellnhofer 696faeb4 2024-03-05T16:17:57 tree: Rework xmlNodeListGetString Use string buffer to avoid quadratic complexity. Handle entities with xmlBufGetNodeContent. Report malloc failures.