Describe the bug
There is an inconsistency in how the XML parser handles improperly formatted XML depending on which function is used.
When loading community-generated maps or meta files, it is common to encounter loose or invalid XML attributes such as (missing the boolean value) or (undeclared namespace).
If you load these files using xmlLoadFile, the parser handles them gracefully and successfully creates the XML node. However, if you read the exact same file contents into a string and use xmlLoadString, the parsing fails and returns false.
Steps to reproduce
- Create a file named test.xml with the following content:
<meta oop>
<info author="test" />
</meta>
- Run the following Lua code:
-- 1. Testing xmlLoadFile (Works)
local xmlFile = xmlLoadFile("test.xml")
if xmlFile then
outputDebugString("xmlLoadFile: SUCCESS")
xmlUnloadFile(xmlFile)
else
outputDebugString("xmlLoadFile: FAILED")
end
-- 2. Testing xmlLoadString (Fails)
local file = fileOpen("test.xml")
local size = fileGetSize(file)
local rawXML = fileRead(file, size)
fileClose(file)
local xmlString = xmlLoadString(rawXML)
if xmlString then
outputDebugString("xmlLoadString: SUCCESS")
xmlUnloadFile(xmlString)
else
outputDebugString("xmlLoadString: FAILED")
end
Expected behavior:
xmlLoadString should have the same fault tolerance as xmlLoadFile. Both functions should ideally be able to parse the same XML structures, especially since xmlLoadString is often needed for custom map loaders or when decrypting downloaded XML files in memory.
Actual behavior:
xmlLoadFile returns the XML node, while xmlLoadString returns false.
Version
Server: v1.6-release-24133
Additional context
No response
Relevant log output
Security Policy
Describe the bug
There is an inconsistency in how the XML parser handles improperly formatted XML depending on which function is used.
When loading community-generated maps or meta files, it is common to encounter loose or invalid XML attributes such as (missing the boolean value) or (undeclared namespace).
If you load these files using
xmlLoadFile, the parser handles them gracefully and successfully creates the XML node. However, if you read the exact same file contents into a string and usexmlLoadString, the parsing fails and returns false.Steps to reproduce
Expected behavior:
xmlLoadString should have the same fault tolerance as xmlLoadFile. Both functions should ideally be able to parse the same XML structures, especially since xmlLoadString is often needed for custom map loaders or when decrypting downloaded XML files in memory.
Actual behavior:
xmlLoadFile returns the XML node, while xmlLoadString returns false.
Version
Server: v1.6-release-24133
Additional context
No response
Relevant log output
Security Policy