Module:Delink: Difference between revisions

From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
simplify bad title check
(decode HTML entities in URLs)
(simplify bad title check)
Line 37:
return delinkReversePipeTrick(s)
end
end
s = mw.uri.decode(s, "PATH") -- decode percent-encoded entities. Leave underscores and plus signs.
s = mw.text.decode(s, true) -- decode HTML entities.
-- Check for bad titles. To do this we need to find the
Line 46 ⟶ 49:
titlearea = mw.ustring.match(s, "^%[%[(.-)%]%]")
end
-- Check for bad characters.
-- If the title area is not a valid title, return the whole string.
if mw.ustring.match(titlearea, v"%[%]<>{}%%%c\n") then
-- Use pcall in case we're over the expensive functions limit.
local goodcall, title = pcall(mw.title.new, titlearea, "")
if not (goodcall and title) then
return s
end
-- Check for characters that are allowed in titles but not in wikilinks.
local other_invalid_link_strings = { '&#x0000;' }
for i,v in ipairs(other_invalid_link_strings) do
if mw.ustring.match(titlearea, v) then
return s
end
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu