Priority: Normal
Current State: Closed
Released In: 2.0.0
Target Release: major
Applies To: Engine
Component: WysiwygPlugin
Branches: Release01x01 trunk master
In some cases the WYSIWYG editor is incorrectly replacing HTML entities.
Reproduce:
- From a default Foswiki install (1.1.2), browse to WebPreferences
- Take note of text and formatting for "web-specific background color, current color"
- Edit page with WYSIWYG editor. Change something (or not), then save.
Result: Above noted text has changed to:
- web-specific background color, #D2D2FF" _mce_style="background-color: <span class="wysiwyg_protected">%webbgcolor%</span>;" class='TMLhtml' > current color
I hope that comes across OK in this report. The less-than and greater-than signs in the 'span's have been replaced with their HTML entities
--
BrianMathis - 02 Dec 2010
Preserving macros inside HTML tags is very difficult. I don't think we support this. In fact I thought we had changes all these occurances to be wrapped with
<sticky>...</sticky>
tags? Are you perhaps editing a
WebPreferences topic which came from an older Foswiki?
--
PaulHarvey - 02 Dec 2010
Sorry, I see that you said you're editing a standard topic. Will investigate.
--
PaulHarvey - 02 Dec 2010
Yes this is editing an older version of
WebPreferences - we no longer include the span with the example color. The original topic contained:
<span style='background-color: %WEBBGCOLOR%'> current color </span>
Inline here:
current color
Setting to confirmed.
--
GeorgeClark - 21 Sep 2011
Crawford, I think I have a possible (but not great) fix:
The fix is down in /WysiwygPlugin/TML2HTML.pm sub _processTags We need to detect that we are inside an HTML tag, and not protect macros there. Some tags are already protected as they are removed earlier in the code, but span makes it through and gets munged up, so you end up with a <span inside the class= of a span, which is completely illegal.
Here is a fix, but probably not 100%, as it doesn't really correctly parse out tags, but it works for the unit tests. It would fail if there are multiple html tags on a single line. We need to detect that we are inside a tag itself, but not inside the contents of the span.
Here is a much better fix I think. It just hides % tags when found inside an <..html...> tag Unit tests all pass with this.
diff --git a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
index a5f1da9..22ac320 100644
--- a/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
+++ b/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
@@ -459,6 +459,8 @@ s/<([A-Za-z]+[^>]*?)((?:\s+\/)?)>/'<' . $this->_protectTag($1, 'TMLhtml') . $2 .
s/\[\[([^]]*)\]\[([^]]*)\]\]/$this->_protectMacrosInSquab($1,$2)/ge;
$text =~ s/\[\[([^\]]*)\]\]/$this->_protectMacrosInSquab($1)/ge;
+ $text =~ s/(<[^>]+>)/$this->_protectMacrosInHTML($1)/ge;
+
# Convert Foswiki tags to spans outside protected text
$text = $this->_processTags($text);
@@ -983,6 +985,14 @@ m/$startww(($Foswiki::regex{webNameRegex}\.)?$Foswiki::regex{wikiWordRegex}($Fos
}
+sub _protectMacrosInHTML {
+ my $this = shift;
+ my $tag = shift;
+
+ $tag =~ s/%/$TT3/g;
+ return $tag;
+}
+
sub _protectMacrosInSquab {
my $this = shift;
my $url = shift;
--
GeorgeClark - 22 Jan 2015
I decided to check this in... Fix looks good, tests all pass. Please set waiting for release if you concur.
--
GeorgeClark - 22 Jan 2015