Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-26161

Allow script macros to output raw HTML instead of wiki syntax

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Unresolved
    • Major
    • None
    • 17.10.0
    • None
    • Unknown

    Description

      Add a rawSyntax parameter to the script macros (Velocity, Groovy, …) to insert the result of the script as raw HTML instead of parsing it as wiki syntax:

      {{velocity rawSyntax="html/5.0"}}
      <div class="foo">$escapetool.xml($value)</div>
      {{/velocity}}
      

      Motivation

      • Security: a value that isn't escaped for XWiki syntax in the output of a script macro can inject wiki syntax, including other script macros. With raw output, missing escaping "only" allows injecting HTML.
      • Performance: a common pattern is a Velocity macro whose content is a single HTML macro, mostly with clean="false". Raw output avoids parsing the whole script output as wiki syntax just to find the end of the HTML macro, and the execution of the nested HTML macro. This helps with large outputs such as job logs (XWIKI-16647).

      Behaviour

      • The output becomes a single raw block in the given syntax, exactly as with the raw macro: all raw block filters are applied, without cleaning (no clean parameter). Content that needs cleaning keeps using the HTML macro.
      • Only syntaxes of the HTML family are accepted for now (e.g. html/5.0, xhtml/1.0); this can be relaxed later. Another syntax is an error.
      • In inline mode the raw block is inserted as is.
      • output="false" still suppresses the output; wiki is ignored when rawSyntax is set.
      • Without rawSyntax, nothing changes.

      The name is consistent with the raw.syntax property of templates, which is the same concept.

      Forum discussion: https://forum.xwiki.org/t/raw-output-for-the-velocity-and-other-script-macros/19155

      Attachments

        Issue Links

          Activity

            People

              MichaelHamann Michael Hamann
              MichaelHamann Michael Hamann
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: