[
https://issues.apache.org/jira/browse/JSPWIKI-684?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18134042#comment-18134042
]
Arturo Bernal commented on JSPWIKI-684:
---------------------------------------
Reproduced with the current code (master plus an unrelated parser change,
Tomcat 10.1, wysiwyg editor). The page from the description, a Table with
CurrentTimePlugin cells and a nested Table, is 337 bytes. Opening it in the
editor and saving without edits makes it 373 bytes, and the cells end up on one
line joined by two backslashes, as described.
The cause is in WhitespaceTrimWriter.replacePluginNewlineBackslashes: the end
of the plugin is found with a non greedy regex that stops at the first closing
brace and bracket, the one of the first nested plugin, so the rest of the outer
plugin keeps the line break markers.
Pull request 559 (https://github.com/apache/jspwiki/pull/559) makes the end of
the plugin the one that balances its opening, and falls back to the first one
when they do not balance. A new test fails without the change and passes with
it, and the wysiwyg and markdown modules pass. I did not repeat the browser
check with the fix, and nesting inside the code blocks with three or two braces
is not changed. Leaving the issue open until the pull request is reviewed.
> Improper interpretation of nested wiki plugin syntax in WYSIWYG mode
> --------------------------------------------------------------------
>
> Key: JSPWIKI-684
> URL: https://issues.apache.org/jira/browse/JSPWIKI-684
> Project: JSPWiki
> Issue Type: Bug
> Components: Editors
> Affects Versions: 2.8.3
> Reporter: Kannan
> Priority: Major
> Labels: pull-request-available
>
> When using FCK editor(WYSIWYG mode) of JSPWiki and using an integrated
> plugin, Table plugin especially, results in an improper formatting of the
> table and also the original edited content of the plugin changed henceforth.
> This occurs only when the plugin is being used with a nested plugin syntax:
> [{Table style='border:3px solid #cccccc;'
> |(text-align:center;font-weight:bold; background:#cccccc;) Hi dear Wiki.
> |<
> |<
> | Date: [{CurrentTimePlugin format='dd:MMM:yyyy'}]
> |Time: [{CurrentTimePlugin format='hh:mm:ss'}]
> | This page: [{$pagename}]
> | [{Table | Nested table | Nested table | Nested table | Nested table }]
> |<
> |< }]
> The above example would not be formatted as expected in WYSIWYG mode and the
> content would also be changed to:
> [{Table style='border:3px solid #cccccc;'
> |(text-align:center;font-weight:bold; background:#cccccc;) Hi dear Wiki.
> |<
> |<
> | Date: [{CurrentTimePlugin format='dd:MMM:yyyy'}] \\ \\|Time:
> [{CurrentTimePlugin format='hh:mm:ss'}] \\ \\| This page:
> [{$pagename}] \\ \\| [{Table | Nested table | Nested table | Nested table |
> Nested table }] \\ \\|< \\ \\|< }]
> after update.
> This is because of the html to wiki markup conversion of WYSIWYG. The issue
> persists in the html element to wiki markup conversion of WYSIWYG in the
> JSPWiki engine. Two backslashes "\\" (a line break in wiki) would be
> introduced for a `<br/>' tag. Though in the final flush stage it would be
> replaced to `\n', the issue persists. This is because the plugin text is
> matched via the regex:
> <snip>
> "\\{\\{\\{(.*?)\\}\\}\\}|\\{\\{(.*?)\\}\\}|\\[\\{(.*?)\\}\\]"
> </snip>
> and this regex can't handle recursive wiki plugin syntax as quoted in the
> example above and would not match the whole wiki content.
> So, the translation would occur for all of the WYSIWYG editor content, but
> the replacement of backslashes could occur only partially and hence the
> backslashes(introduced by the html to wiki translator) could not be replaced
> into `\n' as required and hence we get `\\' between the wiki text. Hence, in
> the table plugin example quote we get `\\' between content owing to nested
> plugin usage.
> The same nested syntax problem exists for the pre-formatted text syntax of
> wiki `{{{' and `{{' too. FWIW, all these would work out of the box with plain
> editor.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)