Modul:Citation/CS1: Redaktələr arasındakı fərq
Redaktənin izahı yoxdur |
Teq: Geri qaytarma |
||
| Sətir 238: | Sətir 238: | ||
--[[--------------------------< L I N K _ P A R A M _ O K >--------------------------------------------------- | |||
checks the content of |title-link=, |series-link=, |author-link= etc for properly formatted content: no wikilinks, no urls | |||
Link parameters are to hold the title of a wikipedia article so none of the WP:TITLESPECIALCHARACTERS are allowed: | |||
# < > [ ] | { } _ | |||
except the underscore which is used as a space in wiki urls and # which is used for section links | |||
returns false when the value contains any of these characters. | |||
When there are no illegal characters, this function returns TRUE if value DOES NOT appear to be a valid url (the | |||
|<param>-link= parameter is ok); else false when value appears to be a valid url (the |<param>-link= parameter is NOT ok). | |||
]] | |||
local function link_param_ok (value) | |||
local scheme, domain; | |||
if value:find ('[<>%[%]|{}]') then -- if any prohibited characters | |||
return false; | |||
end | |||
scheme, domain = split_url (value); -- get scheme or nil and domain or nil from url; | |||
return not is_url (scheme, domain); -- return true if value DOES NOT appear to be a valid url | |||
end | |||
--[[--------------------------< L I N K _ T I T L E _ O K >--------------------------------------------------- | |||
Use link_param_ok() to validate |<param>-link= value and its matching |<title>= value. | |||
|<title>= may be wikilinked but not when |<param>-link= has a value. This function emits an error message when | |||
that condition exists | |||
]] | |||
local function link_title_ok (link, lorig, title, torig) | |||
local orig; | |||
if is_set (link) then -- don't bother if <param>-link doesn't have a value | |||
if not link_param_ok (link) then -- check |<param>-link= markup | |||
orig = lorig; -- identify the failing link parameter | |||
elseif title:find ('%[%[') then -- check |title= for wikilink markup | |||
orig = torig; -- identify the failing |title= parameter | |||
end | |||
end | |||
if is_set (orig) then | |||
table.insert( z.message_tail, { set_error( 'bad_paramlink', orig)}); -- url or wikilink in |title= with |title-link=; | |||
end | |||
end | |||