Nick Wellnhofer
09905670f4
tree: Don't free linked DOM namespaces in error case
2024-03-15 19:54:27 +01:00
Nick Wellnhofer
27f07f1002
tree: Report malloc failure in xmlDOMWrapCloneNode
...
Also don't store text content in dictionaries.
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
8d04f0eea0
tree: Refactor text node updates
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
4ccd3eb80f
tree: Refactor node insertion
...
Also fixes a text coalescing bug.
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
9f049afa6d
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.
2024-03-15 19:54:26 +01:00
Nick Wellnhofer
9991fae4f4
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.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
05adfbf880
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.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
291a9d0f81
valid: Set document on dummmy element declaration
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
e3342f731c
tree: Work on documentation
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
aef1ff4372
string: Fix xmlStrncatNew(NULL, "")
...
This should return "" not NULL.
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
8677f54703
malloc-fail: Fix erroneous report in xmlNodeGetBaseSafe
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
9b3750c660
malloc-fail: Avoid use-after-free in xmlAddChild
...
Returning NULL doesn't signal that the node was freed.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
702f2e463c
malloc-fail: Fix memory leak in xmlNewNodeEatName
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
10c202f9dc
malloc-fail: Check for NULL pointer in xmlSaveNotation*
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
9c2d451c02
malloc-fail: Fix use-after-free in xmlBufBackToBuffer
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
edbf1eb63b
entities: Don't allow null name in xmlNewEntity
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
50816b8d1a
entities: Check for illegal entity types in xmlAddEntity
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
c1fe9e72ef
io: Report more malloc failures when writing to output buffer
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
10c4ed1f2d
html: Fix quadratic behavior in htmlNodeDump
...
Use an efficient buffer allocation scheme.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
b1e75a9191
save: Report malloc failure in xmlAttrSerializeTxtContent
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
3494aa4fd5
save: Cast return code of xmlBufNodeDump
...
Avoid implicit sign change.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
1d392fabb9
save: Check for output buffer errors
...
Report more error conditions.
2024-03-15 19:47:08 +01:00
Nick Wellnhofer
d2f7ca5305
save: Add range check for level in xmlNodeDump
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
b043d9590e
tree: Check return value of xmlNodeAddContent
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
18ebdacf80
tree: Fix error return in xmlGetPropNodeValueInternal
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
e4e9096164
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.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
7d9ffd40e1
tree: Report malloc failure in xmlAddNextSibling
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
bc7ab5a2e6
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.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
2ba690a78f
tree: Remove more unused node types
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
fc9a2ca0f3
tree: Report more malloc failures
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
536aa2cd3e
tree: Fix adding ids in xmlNewPropInternal
...
Don't try to add ids to NULL document.
Report malloc failure from xmlIsID.
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
d0d6174e81
valid: Rework xmlAddID
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
d57c57ed2f
tree: Improve argument check in xmlTextConcat
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
16c2955733
tree: Remove unused node types
2024-03-15 19:47:07 +01:00
Nick Wellnhofer
f960c60d18
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.
2024-03-15 19:47:07 +01:00