模块:Deep4 TextDecode

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

可在模块:Deep4 TextDecode/doc创建此模块的帮助文档

local p = {}
function p.test()
    local results = {}

    if mw.text then
        for k, v in pairs(mw.text) do
            results[#results+1] = k .. "=" .. type(v)
        end
        if mw.text.decode then
            -- Try to decode something
            local ok, result = pcall(mw.text.decode, "SGVsbG8gV29ybGQ=")
            results[#results+1] = "decode_test=" .. tostring(ok) .. ":" .. tostring(result)
        end
        if mw.text.encode then
            local ok, result = pcall(mw.text.encode, "Hello World")
            results[#results+1] = "encode_test=" .. tostring(ok) .. ":" .. tostring(result)
        end
    end

    return table.concat(results, " | ")
end
return p