Module:Delink: Difference between revisions
From the Croc Wiki, the Croc encyclopedia
Jump to navigationJump to search
Content added Content deleted
(decode HTML entities in URLs) |
(simplify bad title check) |
||
Line 37: | Line 37: | ||
return delinkReversePipeTrick(s) |
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 |
-- Check for bad titles. To do this we need to find the |
||
Line 46: | Line 49: | ||
titlearea = mw.ustring.match(s, "^%[%[(.-)%]%]") |
titlearea = mw.ustring.match(s, "^%[%[(.-)%]%]") |
||
end |
end |
||
-- Check for bad characters. |
|||
-- If the title area is not a valid title, return the whole string. |
|||
⚫ | |||
-- 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 |
return s |
||
⚫ | |||
-- Check for characters that are allowed in titles but not in wikilinks. |
|||
local other_invalid_link_strings = { '�' } |
|||
for i,v in ipairs(other_invalid_link_strings) do |
|||
⚫ | |||
return s |
|||
end |
|||
end |
end |
||