# HG changeset patch # User Kim Alvefur # Date 1547643184 -3600 # Node ID ff88b03c343f872160ebeceb394a244531fa64f1 # Parent 7fa273f8869e3b33437f3270f005cad30d5c5e45 util.http: Fix decoding of uppercase URL encoded chars Broken in 1af5106a2c34 diff -r 7fa273f8869e -r ff88b03c343f spec/util_http_spec.lua --- a/spec/util_http_spec.lua Tue Jan 15 20:08:30 2019 +0100 +++ b/spec/util_http_spec.lua Wed Jan 16 13:53:04 2019 +0100 @@ -28,6 +28,11 @@ it("should decode important URL characters", function() assert.are.equal("This & that = something", http.urldecode("This%20%26%20that%20%3d%20something"), "Important URL chars escaped"); end); + + it("should decode both lower and uppercase", function () + assert.are.equal("This & that = {something}.", http.urldecode("This%20%26%20that%20%3D%20%7Bsomething%7D%2E"), "Important URL chars escaped"); + end); + end); describe("#formencode()", function() diff -r 7fa273f8869e -r ff88b03c343f util/http.lua --- a/util/http.lua Tue Jan 15 20:08:30 2019 +0100 +++ b/util/http.lua Wed Jan 16 13:53:04 2019 +0100 @@ -15,6 +15,7 @@ local u = format("%%%02x", i); url_codes[c] = u; url_codes[u] = c; + url_codes[u:upper()] = c; end local function urlencode(s) return s and (s:gsub("[^a-zA-Z0-9.~_-]", url_codes));