Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(threat) tolerate empty namespace URI in namespace declaration #38

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions spec/02-threat_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,21 @@ describe("threats", function()
assert.falsy(r)
end)


it("accepts empty URI", function()
local doc = [[<root xmlns="">txt</root>]]
local r, err = p:parse(doc)
assert.equal(nil, err)
assert.truthy(r)
assert.same({
{ "StartNamespaceDecl" },
{ "StartElement", "root", {} },
{ "CharacterData", "txt" },
{ "EndElement", "root" },
{ "EndNamespaceDecl" }
}, cbdata)
end)

end)


Expand Down
2 changes: 1 addition & 1 deletion src/lxp/threat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function threat.new(callbacks, separator, merge_character_data)
return threat_error("prefix too long")
end

if checks.namespaceUri and #namespaceUri > checks.namespaceUri then
if checks.namespaceUri and namespaceUri and #namespaceUri > checks.namespaceUri then
Tieske marked this conversation as resolved.
Show resolved Hide resolved
return threat_error("namespaceUri too long")
end

Expand Down
Loading