This issue has been created
There is 1 update.
 
 
XWiki Rendering / cid:jira-generated-image-avatar-8aadb060-2e61-4b5a-bd3b-254a9f720f1f XRENDERING-763 Open

The xwiki/2.x renderer break the end macro when the content ends with an odd number of ~

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-26b8b309-301c-4235-b3d5-fb908fc037f4 Thomas Mortagne created this issue on 27/Nov/24 14:58
 
Summary: The xwiki/2.x renderer break the end macro when the content ends with an odd number of ~
Issue Type: cid:jira-generated-image-avatar-8aadb060-2e61-4b5a-bd3b-254a9f720f1f Bug
Affects Versions: Rendering in the platform
Assignee: Unassigned
Components: Syntax - xwiki/2.1
Created: 27/Nov/24 14:58
Priority: cid:jira-generated-image-static-major-c80f9190-d560-4fbd-8ecc-6d637f266099 Major
Reporter: Thomas Mortagne
Description:

When a MacroBlock has "" as content, the xwiki/2.x render does not do anything specific about that ~. For example an info macro with content "" will be serialized as

{{info}}~{{/info}}

The problem is that "~" being an escaping character, the content above is actually the macro info with content "/info".

We need to make sure to properly protect the end macro from the ~.
The difficulty is that in xwiki/2.1 the ~ is not consumed when it's used to escape something which is located in a macro. So doubling the ~~ protects the end macro, but you will actually have ~~ in that macro content. This is something that should ideally be fixed in a xwiki/2.2 syntax, but in the meantime we need to decide the least bad option to stop breaking end macros:

  • escape with ~ despite the problem described above: at least it will behave as expected when the macro contains wiki syntax
  • add an extra white space after the infamous ~: it's not more valid, but at least the hack is a lot less visible for a human
  • a mix:
    • when the Macro indicates that the content type is wiki syntax, escape using ~
    • when we don't know the content type, add an extra white space
 
 

1 update

 
cid:jira-generated-image-avatar-26b8b309-301c-4235-b3d5-fb908fc037f4 Changes by Thomas Mortagne on 27/Nov/24 14:59
 
Description: When a MacroBlock has "~" as content, the xwiki/2.x render does not do anything specific about that ~. For example , an info macro with content "~" will be serialized as :

{noformat}
{{info}}~{{/info}}
{noformat}

The problem is that "~" being an escaping character, the content above is actually the macro info with content "{{/info}}".

We need to make sure to properly protect the end macro from the ~.
The difficulty is that in xwiki/2.1 the ~ is not consumed when it's used to escape something which is located in a macro. So doubling the ~~ protects the end macro, but you will actually have ~~ in that macro content. This is something that should ideally be fixed in a xwiki/2.2 syntax, but in the meantime we need to decide the least bad option to stop breaking end macros:

* escape with ~ despite the problem described above: at least it will behave as expected when the macro contains wiki syntax
* add an extra white space after the infamous ~: it's not more valid, but at least the hack is
a lot less visible for a human
* a mix:
  ** when the Macro indicates that the content type is wiki syntax, escape using ~
  ** when we don't know the content type, add an extra white space


Whatever solution, a slightly bad escaping is better that completely breaking the macro...