* luci/libs: make treatment of "+" conditional in http.protocol ("+" should not be decoded by urldecode)
* luci/https: fix breakage introduced by "+" decoding
This commit is contained in:
parent
bbe086c9ce
commit
8fcbdb39fe
2 changed files with 7 additions and 4 deletions
|
@ -23,14 +23,17 @@ HTTP_URLENC_MAXKEYLEN = 1024 -- maximum allowd size of urlencoded parameter nam
|
||||||
|
|
||||||
-- Decode an urlencoded string.
|
-- Decode an urlencoded string.
|
||||||
-- Returns the decoded value.
|
-- Returns the decoded value.
|
||||||
function urldecode( str )
|
function urldecode( str, no_plus )
|
||||||
|
|
||||||
local function __chrdec( hex )
|
local function __chrdec( hex )
|
||||||
return string.char( tonumber( hex, 16 ) )
|
return string.char( tonumber( hex, 16 ) )
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(str) == "string" then
|
if type(str) == "string" then
|
||||||
|
if not no_plus then
|
||||||
str = str:gsub( "+", " " )
|
str = str:gsub( "+", " " )
|
||||||
|
end
|
||||||
|
|
||||||
str = str:gsub( "%%([a-fA-F0-9][a-fA-F0-9])", __chrdec )
|
str = str:gsub( "%%([a-fA-F0-9][a-fA-F0-9])", __chrdec )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ function Simple.getfile(self, uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Simple.handle_get(self, request, sourcein, sinkerr)
|
function Simple.handle_get(self, request, sourcein, sinkerr)
|
||||||
local file, stat = self:getfile( self.proto.urldecode( request.env.PATH_INFO ) )
|
local file, stat = self:getfile( self.proto.urldecode( request.env.PATH_INFO, true ) )
|
||||||
|
|
||||||
if stat then
|
if stat then
|
||||||
if stat.type == "regular" then
|
if stat.type == "regular" then
|
||||||
|
@ -95,7 +95,7 @@ function Simple.handle_get(self, request, sourcein, sinkerr)
|
||||||
elseif stat.type == "directory" then
|
elseif stat.type == "directory" then
|
||||||
|
|
||||||
local ruri = request.request_uri:gsub("/$","")
|
local ruri = request.request_uri:gsub("/$","")
|
||||||
local duri = self.proto.urldecode( ruri )
|
local duri = self.proto.urldecode( ruri, true )
|
||||||
local root = self.docroot:gsub("/$","")
|
local root = self.docroot:gsub("/$","")
|
||||||
|
|
||||||
-- check for index files
|
-- check for index files
|
||||||
|
|
Loading…
Reference in a new issue