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 created this task.Jun 21 2017, 11:45 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJun 21 2017, 11:45 PM
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 closed this task as Invalid.Jun 22 2017, 1:32 PM
Anomie added a subscriber: Anomie.

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.

Aklapper removed a subscriber: Anomie.Oct 16 2020, 5:28 PM