diff --git a/CHANGELOG b/CHANGELOG
index 15daddee0..f1de75fd9 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -92,6 +92,10 @@ o [NSE] Fixed url.parse_query, which raised a Lua error on every call due to
passing the query string as the gsub pattern. Plus-to-space decoding is
restored.
+o [NSE][GH#3324] url.parse_query no longer performs incomplete HTML entity
+ decoding (& < >) that could mis-split query strings. Callers that
+ need HTML decoding should do it explicitly.
+
o [Ncat][GH#3005] Correctly report listening port number. `ncat -l -p 0` will
cause Ncat to listen on an ephemeral port, but it was reporting itself as
listening on port 0.
diff --git a/nselib/url.lua b/nselib/url.lua
index 1a5ff5f62..01411626c 100644
--- a/nselib/url.lua
+++ b/nselib/url.lua
@@ -354,11 +354,6 @@ function build_path(parsed, unsafe)
return table.concat(path)
end
-local entities = {
- ["amp"] = "&",
- ["lt"] = "<",
- ["gt"] = ">"
-}
---
-- Breaks a query string into name/value pairs.
--
@@ -372,12 +367,6 @@ local entities = {
-- table["name"] = value.
-----------------------------------------------------------------------------
function parse_query(query)
-
- -- TODO: https://github.com/nmap/nmap/issues/3324
- -- This opportunistic HTML decoding is problematic because
- -- it might accidentally decode what should not be decoded.
- query = string.gsub(query, "&([ampltg]+);", entities)
-
local parsed = {}
for qseg in query:gsub("%+", " "):gmatch("[^&]+") do
local k, v = qseg:match("^([^=]*)=?(.*)")
@@ -517,6 +506,8 @@ local parse_query_tests = {
{"foo=1&bar=2", {foo = "1", bar = "2"}},
{"a+b=c+d", {["a b"] = "c d"}},
{"a%20b=c%26d", {["a b"] = "c&d"}},
+ -- names/values must not be HTML-entity-decoded (#3324)
+ {"kt;=11<=22", {["kt;"] = "11", ["lt;"] = "22"}},
}
for k, v in ipairs(parse_query_tests) do
local query, expected = table.unpack(v)