You are here: Foswiki>Tasks Web>Item13178 (05 Jul 2015, GeorgeClark)Edit Attach

Item13178: TinyMCEPlugin permanently expands tags in some square bracket links.

pencil
Priority: Urgent
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Extension
Component: TinyMCEPlugin
Branches: master
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
If a tag is written as
[[%TOPIC%]]

TML2HTML converts this to:

<a href="TestEditTable" class="TMLlink">%TOPIC%</a></p>

After save, the topic contains
[[TestEditTable][%TOPIC%]]

I added a unit test (locally) and the expansion of Item13178 does not happen. So this can't be detected by the unit tests.

See http://trunk.foswiki.org/Sandbox/TestEditTable

-- GeorgeClark - 23 Dec 2014

The following unit test passes fine:

diff --git a/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm b/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
index d945d26..809b925 100644
--- a/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
+++ b/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
@@ -1284,6 +1284,17 @@ escaped:
 THERE
     },
     {
+        exec => ROUNDTRIP | TML2HTML | HTML2TML,
+        name => 'squabsWithVars3',
+        html => <<HERE,
+<p><a class='TMLlink' href="%TOPIC%">%TOPIC%</a>
+</p>
+HERE
+        tml => <<'THERE',
+[[%TOPIC%]]
+THERE
+    },
+    {
         exec => ROUNDTRIP,
         name => 'squabsWithWikiWordsAndLink',
         html => $LINKON

-- GeorgeClark - 23 Dec 2014

Bumping this to Urgent. I tried to edit PatternSkinCssCookbook, and it was damaged. All instances of %SYSTEMWEB% in URL's were changed to System For ex:
-   * [[%PUBURLPATH%/%SYSTEMWEB%/PatternSkinTheme/layout.css][layout.css]] - the positioning of main page elements (blocks), widths and heights
-   * [[%PUBURLPATH%/%SYSTEMWEB%/PatternSkinTheme/style.css][style.css]] - fonts, sizes, margins and paddings
-   * [[%PUBURLPATH%/%SYSTEMWEB%/PatternSkinTheme/colors.css][colors.css]] - border colors, text colors and background colors
+   * [[%PUBURLPATH%/System/PatternSkinTheme/layout.css][layout.css]] - the positioning of main page elements (blocks), widths and heights
+   * [[%PUBURLPATH%/System/PatternSkinTheme/style.css][style.css]] - fonts, sizes, margins and paddings
+   * [[%PUBURLPATH%/System/PatternSkinTheme/colors.css][colors.css]] - border colors, text colors and background colors

See also Item8966. In addition to the macro change, all the <nop> in use to escape macros were removed, and it wiped out the skin settings.

-- GeorgeClark - 23 Feb 2015

This issue is also in Foswiki 1.1.9, so maybe it shouldn't be urgent. I found the problem, but I'm not sure what to do about it. The problem is in foswiki_tiny.js. It expands macros in links. I believe it should only do it for image links, so that they can be rendered, but it's doing it to the left side of square bracket links.

Any macro defined in FoswikiTiny foswikiVars will be expanded: Currently the list is:

ATTACHURL   "http://foswiki.testsite...m/pub/Sandbox/TestNOP"
ATTACHURLPATH   "/pub/Sandbox/TestNOP"
PUBURL   "http://foswiki.testsite.com/pub"
PUBURLPATH   "/pub"
SCRIPTSUFFIX   ""
SCRIPTURL   "http://foswiki.testsite.com/bin"
SYSTEMWEB   "System"
TOPIC   "TestTopic"
VIEWSCRIPTURL   "http://foswiki.testsite.com"
WEB   "Sandbox"

-- GeorgeClark - 24 Feb 2015

The FoswikiTiny.convertLink function is called for each URL, configured per: http://www.tinymce.com/wiki.php/Configuration3x:urlconverter_callback.

In pondering this a bit, I wonder if the issue was caused back around 1.1.5, distro:9c9ec60b16c4, when I implemented the code to render TML links as HTML links instead of simulated links. As =convertLink is passed the 'node', can that be used check the class, and skip expanding variables for TML links?

-- GeorgeClark - 24 Feb 2015

Looks like the passed node is not useful. It appears to only contain the name of the tag, in this case a.

-- GeorgeClark - 24 Feb 2015

See http://trunk.foswiki.org/Sandbox/TestItem13178 for examples. Don't save topic, view conversion with wikitext button.

-- GeorgeClark - 28 Feb 2015

Part 1 of fix: Since SYSTEMWEB, WEB and TOPIC macros are not "reversed" in WysiwygPlugin, don't expand those 3 macros in tinymce. Checked in.

Part 2. This is caused by short URLs. foswik_tiny assumes that if the "view url" is the prefix of a http:... url, then the format is always web.topic. But with short URLs, the view url is always contained as the prefix of other URLs, so it needs an exception when short URLs are active. In this case it appears that WysiwygPlugin also makes the same mistake, so a fix is also needed in the perl code.

-- GeorgeClark - 28 Feb 2015
 
Topic revision: r10 - 05 Jul 2015, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy