Page MenuHomePhabricator

{{#invoke:mymodule|showpage|{{#tag:categorytree|TestCategory|hideroot="true"|namespaces="-"}} }} results in strip markers being output
Closed, InvalidPublic

Description

Reported on IRC by KataiKou

on the MW page:

{{#invoke:mymodule|showpage|{{#tag:categorytree|TestCategory|hideroot="true"|namespaces="-"}} }}

And mymodule contents

local p = {}
 
function html_escape(s)
    assert("Expected string in argument #1.")
    return (string.gsub(s, "[}{\">/<'&]", {
        ["&"] = "&amp;",
        ["<"] = "&lt;",
        [">"] = "&gt;",
        ['"'] = "&quot;",
        ["'"] = "&#39;",
        ["/"] = "&#47;"
    }))
end
 
function p.showpage(frame)
  local result = ''
 
  for name, value in pairs(frame.args) do
    result = result .. ' ' .. name .. '=' .. html_escape(value) .. '\n'
  end
 
  return result
end
 
 
 
return p

Event Timeline

Reedy renamed this task from {{#invoke:mymodule|showpage|{{#tag:categorytree|TestCategory|hideroot="true"|namespaces="-"}} }}results in strip markers being output to {{#invoke:mymodule|showpage|{{#tag:categorytree|TestCategory|hideroot="true"|namespaces="-"}} }} results in strip markers being output.Jun 21 2017, 11:45 PM
Reedy updated the task description. (Show Details)
Anomie subscribed.

If you use string manipulation to break the strip marker, then of course you'll get something resembling strip markers in the output. Use mw.text.killMarkers() to remove them before encoding your values, or mw.text.unstrip() to unstrip <nowiki> markers and remove the rest.