rehamaltamimi / gwtwiki

Automatically exported from code.google.com/p/gwtwiki
0 stars 0 forks source link

html output is invalid for some images with inline quotes #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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.j
pg\""
                        + " 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]]"));
    }

Original issue reported on code.google.com by michael....@gmail.com on 3 Nov 2009 at 12:05

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
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 "der Sektkellerei"
Henkell & Söhnlein KG\">"
                        + "<img
src=\"http://www.bliki.info/wiki/Henkell-Schl%C3%B6sschen.JPG\""
                        + " alt=\"Henkell-Schlösschen "der Sektkellerei"
Henkell & Söhnlein KG\""
                        + " title=\"Henkell-Schlösschen "der Sektkellerei"
Henkell & Söhnlein KG\""
                        + " class=\"location-none type-thumb\" />\n"
                        + "</a>\n"
                        + "<div class=\"thumbcaption\"><i>Henkell-Schlösschen</i>"
                        + " "der Sektkellerei" <a
href=\"http://www.bliki.info/wiki/Henkell_%26_S%C3%B6hnlein_KG\""
                        + " title=\"Henkell & Söhnlein KG\">"
                        + "Henkell & 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 & 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"));
    }

Original comment by michael....@gmail.com on 3 Nov 2009 at 3:02

GoogleCodeExporter commented 8 years ago
Changed in SVN:
http://code.google.com/p/gwtwiki/source/detail?r=525

Original comment by axelclk@gmail.com on 3 Nov 2009 at 7:15

GoogleCodeExporter commented 8 years ago

Original comment by axelclk@gmail.com on 5 Jan 2010 at 7:24