Modul:Sandkasse/Sechinsic/uriencodeTST
Udseende
local p = {}
p.m = function (P)
local str = "<strong>uri.encode eller ikke<strong><p><q>It is impossible to encode a URL without knowing about its specific parts.</q> [http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding] <p>Præmissen er at den url der bruges i {{para|url}}, {{para|url2}} og {{para|tilgang}} allerede er url-encoded.<p>Sikkerhedsmæssigt er (øhh) modulet her kun en dråbe i det store Wikipedia-hav. Der er ikke noget specifikt for netop modulet her der gør modulet mere fortrinligt for en hacker - i hvert fald hvad angår url-skemaet. Det er jo også heldigt nok, for dette moduls script design/layout/stil er virkelig kun målrettet formateringen af kildeangivelser!<dl>"
local prot = { "http://", "https://", "[a-z]+://" }
local exa = {
"www.eurocodes.dk/",
"https://lists.w3.org/Archives/Public/public-html/2012Nov/0177.html",
"http://jakoblog.de/2009/05/10/who-identifies-the-identifiers/",
"http://www.telegraph.co.uk/culture/tvandradio/3621779/The-return-of-the-secondary-modern.html",
"http://www.landesmuseum.at/eisenzeiten/eisenzeiten%20I%20pdfs/Amann.pdf",
"http://books.google.com/books?as_isbn=3406529577",
"http://www.mtp.hum.ku.dk/details.asp?eln=200114",
"http://www.sun.com:80/index.html",
}
for k,v in ipairs (exa) do
if (v: find ("^" .. prot[1])) then
str = str .. "<dt>mw encode PATH/QUERY:  " .. v .. " " .. "</dt>"
.. "<dd><ol><li>  "
.. prot[1] .. mw.uri.encode(v: gsub ("^" .. prot[1],""),"PATH"): gsub ("%%2[fF]","/")
.. "  <li>  ["
.. prot[1] .. mw.uri.encode(v: gsub ("^" .. prot[1],""),"PATH"): gsub ("%%2[fF]","/")
.. " link]  </ol></dd><dd><ol><li>  "
.. prot[1] .. mw.uri.encode(v: gsub ("^" .. prot[1],""),"QUERY"): gsub ("%%2[fF]","/")
.. "  <li>  ["
.. prot[1] .. mw.uri.encode(v: gsub ("^" .. prot[1],""),"QUERY"): gsub ("%%2[fF]","/")
.. " link]  </ol></dd>"
elseif (v: find ("^" .. prot[2])) then
str = str .. "<dt>mw encode PATH/QUERY:  " .. v .. " " .. "</dt>"
.. "<dd><ol><li>  "
.. prot[2] .. mw.uri.encode(v: gsub ("^" .. prot[2],""),"PATH"): gsub ("%%2[fF]","/")
.. "  <li>  ["
.. prot[2] .. mw.uri.encode(v: gsub ("^" .. prot[2],""),"PATH"): gsub ("%%2[fF]","/")
.. " link]  </ol></dd><dd><ol><li>  "
.. prot[2] .. mw.uri.encode(v: gsub ("^" .. prot[2],""),"QUERY"): gsub ("%%2[fF]","/")
.. "  <li>  ["
.. prot[2] .. mw.uri.encode(v: gsub ("^" .. prot[2],""),"QUERY"): gsub ("%%2[fF]","/")
.. " link]  </ol></dd>"
elseif (not (v: find ("^" .. prot[3]))) then
str = str .. "<dt>mw encode PATH/QUERY:  " .. v .. " " .. "</dt>"
.. "<dd><ol><li>  "
.. mw.uri.encode(v: gsub ("^" .. prot[2],""),"PATH"): gsub ("%%2[fF]","/")
.. "  <li>  ["
.. mw.uri.encode(v,"PATH"): gsub ("%%2[fF]","/")
.. " link]  </ol></dd><dd><ol><li>  "
.. mw.uri.encode(v,"QUERY"): gsub ("%%2[fF]","/")
.. "  <li>  ["
.. mw.uri.encode(v,"QUERY"): gsub ("%%2[fF]","/")
.. " link]  </ol></dd>"
else
str = str .. "<dt>Uforudset fejl.</dt><dd>  " .. v .. "  </dd>"
end
end
return str .. "</dl>"
end
return p