Modul:UrlCheck: Unterschied zwischen den Versionen
K
handling utf-8 in path
KKeine Bearbeitungszusammenfassung |
K (handling utf-8 in path) |
||
| Zeile 31: | Zeile 31: | ||
end | end | ||
local s = mw.text.trim( url ), count | local s = mw.text.trim( url ), count, i | ||
if s == '' then | if s == '' then | ||
return 3 | return 3 | ||
| Zeile 69: | Zeile 69: | ||
-- path check | -- path check | ||
if not skipPathCheck and aPath ~= '' | if not skipPathCheck and aPath ~= '' then | ||
-- replacing utf-8 characters > \x7F | |||
for i = 1, #aPath, 1 do | |||
if aPath:byte( i ) > 127 then | |||
aPath = aPath:sub( 1, i - 1 ) .. 'a' .. aPath:sub( i + 1 ) | |||
end | |||
end | |||
if not aPath:match( '^[-A-Za-z0-9_.,~%%%+&:;#*?!=()@/]*$' ) then | |||
return 23 | |||
end | |||
end | end | ||
| Zeile 168: | Zeile 175: | ||
function uc.checkUrl( frame ) | function uc.checkUrl( frame ) | ||
local args = frame.args | local args = frame.args | ||
args.url = args.url or '' | local pArgs = frame:getParent().args | ||
args.show = args.show or '' | args.url = args.url or pArgs.url or '' | ||
args.show = args.show or pArgs.show or '' | |||
local result = uc.isUrl( args.url, false ) | local result = uc.isUrl( args.url, false ) | ||
| Zeile 184: | Zeile 192: | ||
function uc.encodePath( frame ) | function uc.encodePath( frame ) | ||
local args = frame.args | local args = frame.args | ||
args.url = args.url or args[ 1 ] or '' | local pArgs = frame:getParent().args | ||
args.url = args.url or args[ 1 ] or pArgs.url or pArgs[ 1 ] or '' | |||
return uc.uriEncodePath( args.url ) | return uc.uriEncodePath( args.url ) | ||
end | end | ||
return uc | return uc | ||