Usuario anónimo
sin resumen de edición
m (1 revisión importada) |
wikitves>Techso01 Sin resumen de edición |
||
Línea 280: | Línea 280: | ||
end | end | ||
return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str }); | return table.concat({ "[", URL, " ", safeforurl( label ), "]", error_str }); | ||
end | |||
--[[--------------------------< H D L >------------------------------------------------------------------------ | |||
Formats an HDL with minor error checking. | |||
HDL names contain two parts: prefix and suffix separated by a forward slash. | |||
Prefix: character string using any character in the UCS-2 character set except '/' | |||
Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant | |||
This function checks a HDL name for: prefix/suffix. If the HDL name contains spaces, endashes, or, if it ends | |||
with a period or a comma, this function will emit a bad_hdl error message. | |||
HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and | |||
terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely | |||
if ever used in HDLs. | |||
Query string parameters are named here: http://www.handle.net/proxy_servlet.html. query strings are not displayed | |||
but since '?' is an allowed character in an HDL, '?' followed by one of the query parameters is the only way we | |||
have to detect the query string so that it isn't URL-encoded with the rest of the identifier. | |||
]] | |||
local function hdl (options) | |||
local id = options.id; | |||
local access = options.access; | |||
local handler = options.handler; | |||
local query_params = { -- list of known query parameters from http://www.handle.net/proxy_servlet.html | |||
'noredirect', | |||
'ignore_aliases', | |||
'auth', | |||
'cert', | |||
'index', | |||
'type', | |||
'urlappend', | |||
'locatt', | |||
'action', | |||
} | |||
local hdl, suffix, param = id:match ('(.-)(%?(%a+).+)$'); -- look for query string | |||
local found; | |||
if hdl then -- when there are query strings, this is the handle identifier portion | |||
for _, q in ipairs (query_params) do -- spin through the list of query parameters | |||
if param:match ('^' .. q) then -- if the query string begins with one of the parameters | |||
found = true; -- announce a find | |||
break; -- and stop looking | |||
end | |||
end | |||
end | |||
if found then | |||
id = hdl; -- found so replace id with the handle portion; this will be URL-encoded, suffix will not | |||
else | |||
suffix = ''; -- make sure suffix is empty string for concatenation else | |||
end | |||
local text = external_link_id ({link = handler.link, label = handler.label, q = handler.q, redirect = handler.redirect, | |||
prefix = handler.prefix, id = id, suffix = suffix, separator = handler.separator, encode = handler.encode, access = access}) | |||
if nil == id:match("^[^%s–]-/[^%s–]-[^%.,]$") then -- HDL must contain a forward slash, must not contain spaces, endashes, and must not end with period or comma | |||
set_message ('err_bad_hdl' ); | |||
options.coins_list_t['HDL'] = nil; -- when error, unset so not included in COinS | |||
end | |||
return text; | |||
end | end | ||
--[[--------------------------< N O R M A L I Z E _ L C C N >-------------------------------------------------- | --[[--------------------------< N O R M A L I Z E _ L C C N >-------------------------------------------------- | ||
Línea 852: | Línea 917: | ||
elseif k == 'DOI' then | elseif k == 'DOI' then | ||
table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } ); | table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } ); | ||
elseif k == 'HDL' then | |||
table.insert( new_list, {handler.label, hdl( v ) } ); | |||
elseif k == 'LCCN' then | elseif k == 'LCCN' then | ||
table.insert( new_list, {handler.label, lccn( v ) } ); | table.insert( new_list, {handler.label, lccn( v ) } ); |