Completely fix internet patch?

Take 2 ... 3 ... 11?
Remove the default port from the https library, preventing injection of
port 443
Remove the default port from the http library, preventing injection of
port 80
Check specifically for https, injecting port 443, else 80
This commit is contained in:
gamax92 2015-06-23 14:52:46 -06:00
parent b6aeb90d67
commit 618504f9cd
2 changed files with 5 additions and 1 deletions

View File

@ -11,6 +11,8 @@ local httpsok, http = pcall(require, "ssl.https")
if not httpsok then if not httpsok then
cprint("Cannot use HTTPS: " .. http) cprint("Cannot use HTTPS: " .. http)
http = require("socket.http") http = require("socket.http")
else
http.PORT = nil
end end
component.connect("filesystem",gen_uuid(),nil,"lua/component/internet",true) component.connect("filesystem",gen_uuid(),nil,"lua/component/internet",true)

View File

@ -7,7 +7,9 @@ cprint("http_patch start")
-- Patch data -- Patch data
local patches = { local patches = {
{[[if headers[name] then headers[name] = headers[name] .. ", " .. value]],[[if headers[name] then if type(headers[name]) == "string" then headers[name] = {headers[name]} end headers[name][#headers[name]+1] = value]]}, {[[if headers[name] then headers[name] = headers[name] .. ", " .. value]],[[if headers[name] then if type(headers[name]) == "string" then headers[name] = {headers[name]} end headers[name][#headers[name]+1] = value]]},
{[[local nreqt = adjustrequest(reqt)]],[[local nreqt = adjustrequest(reqt) if nreqt.scheme == "http" then nreqt.create = nil if nreqt.port == "443" then nreqt.port = "80" end end]]}, {[[local nreqt = adjustrequest(reqt)]],[[local nreqt = adjustrequest(reqt) if nreqt.scheme == "http" then nreqt.create = nil end]]},
{[[_M.PORT = 80]],[[]]},
{[[if nreqt.port == "" then nreqt.port = 80 end]],[[if nreqt.port == "" or nreqt.port == nil then if nreqt.scheme == "https" then nreqt.port = "443" else nreqt.port = "80" end end]]}
} }
package.loaded["socket.http"] = nil package.loaded["socket.http"] = nil
local path = package.searchpath("socket.http",package.path) local path = package.searchpath("socket.http",package.path)