Issue 25 in gwtwiki: html output is invalid for some images with inline quotes

3 views
Skip to first unread message

gwt...@googlecode.com

unread,
Nov 2, 2009, 7:06:10 PM11/2/09
to bl...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 25 by michael.blakeley: html output is invalid for some images
with inline quotes
http://code.google.com/p/gwtwiki/issues/detail?id=25

What steps will reproduce the problem?
1. Render wikitext like this to html:

[[Image:William Fettes Douglas - The Alchemist.jpg|thumb|left|\"Renel the
Alchemist\", by Sir William Douglas, 1853]]

What is the expected output? What do you see instead?
The output html should encode the double-quotes in html attributes, but
does not.

What version of the product are you using? On what operating system?
svn rev 524.

Please provide any additional information below.

It's odd, because escaping seems to work in WPImageFilterTest.java
testImage06
([[Image:Henkell-Schlösschen.JPG|thumb|\'\'Henkell-Schlösschen\'\' der
Sektkellerei [[Henkell & Söhnlein KG]]]] Wiesbaden).

Here's a test case, which I believe to be correct. It should go into
WPImageFilterTest.java

public void testImage14() {
assertEquals(
"\n"
+ "<p><a class=\"internal\"
href=\"http://www.bliki.info/wiki/Image:William_Fettes_Douglas_-_The_Alchemist.jpg\""
+ " title=\"&quot;Renel the Alchemist&quot;, by Sir
William Douglas, 1853\">"
+ "<img
src=\"http://www.bliki.info/wiki/William_Fettes_Douglas_-_The_Alchemist.jpg\""
+ " alt=\"&quot;Renel the Alchemist&quot;, by Sir
William Douglas, 1853\""
+ " title=\"&quot;Renel the Alchemist&quot;, by Sir
William Douglas, 1853\""
+ " class=\"location-none type-thumb\" />\n"
+ "</a>\n"
+ "<div class=\"thumbcaption\">&quot;Renel the
Alchemist&quot;, by Sir William Douglas, 1853"
+ "<a
href=\"http://www.bliki.info/wiki/William_Fettes_Douglas_-_The_Alchemist.jpg\""
+ " title=\"&quot;Renel the Alchemist&quot;, by Sir
William Douglas, 1853\">"
+ "&quot;Renel the Alchemist&quot;, by Sir William
Douglas, 1853</a></div></p>",
wikiModel
.render("[[Image:William Fettes Douglas - The
Alchemist.jpg|thumb|left|\"Renel the Alchemist\", by Sir William Douglas,
1853]]"));
}


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

gwt...@googlecode.com

unread,
Nov 2, 2009, 7:12:14 PM11/2/09
to bl...@googlegroups.com

Comment #1 on issue 25 by michael.blakeley: html output is invalid for some

Or perhaps the preferred style is &#34; instead of &quot;

Interestingly, the body text is encoded but the attribute text is not.

gwt...@googlecode.com

unread,
Nov 2, 2009, 10:03:13 PM11/2/09
to bl...@googlegroups.com

Comment #2 on issue 25 by michael.blakeley: html output is invalid for some
I have a fix working, changes to AbstractWikiModel.java only.

In appendRawWikipediaLink(), remove the line:

rawTopicName = Encoder.encodeHtml(rawTopicName);

In appendInternalImageLink(), do the encoding (close to line 396):

altAttribute =
captionTagNode.getBodyString();
- imageFormat.setAlt(altAttribute);
+ imageFormat.setAlt(Encoder.encodeHtml(altAttribute));

This breaks a couple of test cases, but I believe the test cases are wrong.
WPImageFilterTest.testImage06 and WPLinkFilterTest.testLink12 both seem to
double-escape amps in their expected results.

public void testImage06() {
assertEquals(
"\n"
+ "<p><a class=\"internal\"
href=\"http://www.bliki.info/wiki/Image:Henkell-Schl%C3%B6sschen.JPG\""
+ " title=\"Henkell-Schlösschen &quot;der
Sektkellerei&quot;
Henkell &amp; Söhnlein KG\">"
+ "<img
src=\"http://www.bliki.info/wiki/Henkell-Schl%C3%B6sschen.JPG\""
+ " alt=\"Henkell-Schlösschen &quot;der
Sektkellerei&quot;
Henkell &amp; Söhnlein KG\""
+ " title=\"Henkell-Schlösschen &quot;der
Sektkellerei&quot;
Henkell &amp; Söhnlein KG\""
+ " class=\"location-none type-thumb\" />\n"
+ "</a>\n"
+ "<div
class=\"thumbcaption\"><i>Henkell-Schlösschen</i>"
+ " &#34;der Sektkellerei&#34; <a
href=\"http://www.bliki.info/wiki/Henkell_%26_S%C3%B6hnlein_KG\""
+ " title=\"Henkell &amp; Söhnlein KG\">"
+ "Henkell &#38; Söhnlein KG</a></div>
Wiesbaden</p>",
wikiModel

.render("[[Image:Henkell-Schlösschen.JPG|thumb|\'\'Henkell-Schlösschen\'\'
\"der
Sektkellerei\" [[Henkell & Söhnlein KG]]]] Wiesbaden"));
}

public void testLink12() {
assertEquals(
"\n"
+ "<p>kellereien wie "
+ "<a
href=\"http://www.bliki.info/wiki/Henkell_%26_S%C3%B6hnlein\""
+ " title=\"Henkell &amp; Söhnlein\">Henkell</a>,"
+ " <a
href=\"http://www.bliki.info/wiki/S%C3%B6hnlein\""
+ " title=\"Söhnlein\">Söhnlein</a></p>",
wikiModel
.render("kellereien wie [[Henkell & Söhnlein|
Henkell]],
[[Söhnlein]]"));
Set<String> set = wikiModel.getLinks();
assertTrue(set.contains("Söhnlein"));
assertTrue(set.contains("Henkell & Söhnlein"));

gwt...@googlecode.com

unread,
Nov 3, 2009, 2:16:17 PM11/3/09
to bl...@googlegroups.com
Updates:
Owner: axelclk

Comment #3 on issue 25 by axelclk: html output is invalid for some images

Changed in SVN:
http://code.google.com/p/gwtwiki/source/detail?r=525

gwt...@googlecode.com

unread,
Jan 5, 2010, 2:43:55 PM1/5/10
to bl...@googlegroups.com
Updates:
Status: Fixed

Comment #4 on issue 25 by axelclk: html output is invalid for some images

(No comment was entered for this change.)

Reply all
Reply to author
Forward
0 new messages