emit error if QID is not of the form Q12345 in the right place

This commit is contained in:
Jonathan Harker 2026-11-02 13:22:00 +13:00
parent 1bd831ae65
commit 1ddf3a5758

View file

@ -569,14 +569,6 @@ local function _cite_q (citeq_args)
citeq_args.wdl = nil citeq_args.wdl = nil
citeq_args.template = nil citeq_args.template = nil
-- QID as normal form; emit error if not ^Q%d+$ (e.g. a Wikidata URL)
local qid_form = mw.ustring.match(mw.text.trim(qid), "^Q%d+$") or nil
if qid_form then
qid = qid_form
else
cq_errors = cq_errors .. ' <span class="error" style="font-size:inherit"><code class="cs1-code">{{[[Template:Cite Q|Cite Q]]}}</code>: QID parameter must be supplied as "Q" followed by digits, e.g. <code class="cs1-code">Q12345</code> ([[Template:Cite Q#Error messages|help]])</span> '
end
-- if title supplied, flag to not read html title -- if title supplied, flag to not read html title
local titleforced = (citeq_args.title ~= nil) local titleforced = (citeq_args.title ~= nil)
@ -1155,6 +1147,12 @@ local function cite_q (frame)
args.language = args.language or args.lang args.language = args.language or args.lang
args.lang = nil args.lang = nil
-- QID as normal form; emit error if not ^Q%d+$ (e.g. a Wikidata URL)
local qid_form = mw.ustring.match(mw.text.trim(args.qid), "^Q%d+$") or nil
if not qid_form then
return ' <span class="error" style="font-size:inherit"><code class="cs1-code">{{[[Template:Cite Q|Cite Q]]}}</code>: QID parameter must be supplied as "Q" followed by digits, e.g. <code class="cs1-code">Q12345</code> ([[Template:Cite Q#Error messages|help]])</span> '
end
local cites = {} local cites = {}
for q in args.qid:gmatch("Q%d+") do for q in args.qid:gmatch("Q%d+") do
-- make a new copy of the arguments -- make a new copy of the arguments