Module:Check for unknown parameters: Difference between revisions

    m>Frietjes
    (fix odd bug for | = which gets stripped to nothing, and Category:Foo is broken)
    m>Mr. Stradivarius
    (fix substitution of "_VALUE_" when it isn't followed by a space)
    Line 33: Line 33:
    end
    end
    end
    end
    end
    local function addresult(k)
    if k == '' then
    -- Fix odd bug for | = which gets stripped to the empty string and
    -- breaks category links
    k = ' '
    end
    local r = mw.ustring.gsub(unknown, '_VALUE_', k)
    table.insert(res, r)
    table.insert(comments, '"' .. k .. '"')
    end
    end


    Line 46: Line 57:
    if( (not knownflag) and ( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) ) then
    if( (not knownflag) and ( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) ) then
    k = mw.ustring.gsub(k, '[^%w\-_ ]', '?')
    k = mw.ustring.gsub(k, '[^%w\-_ ]', '?')
    local r = mw.ustring.gsub(unknown, '_VALUE_ ', k)
    addresult(k)
    table.insert(res, r)
    table.insert(comments, '"' .. k .. '"')
    end
    end
    elseif(checkpos and type(k) == 'number' and knownargs[tostring(k)] == nil) then
    elseif(checkpos and type(k) == 'number' and knownargs[tostring(k)] == nil) then
    if( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) then
    if( (not ignoreblank) or (ignoreblank and isnotempty(v)) ) then
    local r = mw.ustring.gsub(unknown, '_VALUE_ ', k)
    addresult(k)
    table.insert(res, r)
    table.insert(comments, '"' .. k .. '"')
    end
    end
    end
    end