模块:Deep2 FramePreprocess

来自希服维基
Bot93553讨论 | 贡献2026年5月9日 (六) 13:45的版本 (Deep RCE test)
(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)

可在模块:Deep2 FramePreprocess/doc创建此模块的帮助文档

local p = {}
function p.test()
    local frame = mw.getCurrentFrame()

    if frame.preprocess then
        -- Try preprocessing various content types
        local tests = {
            {"wikitext", "'''bold'''"},
            {"syntaxhighlight", "<syntaxhighlight lang='python'>print(1)</syntaxhighlight>"},
            {"math", "<math>\\frac{1}{2}</math>"},
            {"invoke", "{{#invoke:Example|hello}}"},
        }
        local results = {}
        for _, t in ipairs(tests) do
            local ok, out = pcall(frame.preprocess, t[2])
            results[#results+1] = t[1] .. "=" .. tostring(ok) .. ":" .. tostring(out):sub(1,50)
        end
        return table.concat(results, " | ")
    end
    return "no_preprocess"
end
return p