http://www.mediawiki.org/wiki/Special:Code/MediaWiki/82843

Revision: 82843
Author:   btongminh
Date:     2011-02-26 12:08:59 +0000 (Sat, 26 Feb 2011)
Log Message:
-----------
(bug 27679) Broken embedded files with special characters are no longer double 
HTML escaped
Was a double escape in Linker::makeBrokenImageLinkObj. I checked the callers 
and other usages in the function and $prefix and $inside appear to be assumed 
HTML fragments
Added parser tests: Passed 622 of 624 tests (99.68%)... 2 tests failed! Those 
two tests already failed for me before this patch

Modified Paths:
--------------
    trunk/phase3/RELEASE-NOTES
    trunk/phase3/includes/Linker.php
    trunk/phase3/tests/parser/parserTests.txt

Modified: trunk/phase3/RELEASE-NOTES
===================================================================
--- trunk/phase3/RELEASE-NOTES  2011-02-26 12:08:45 UTC (rev 82842)
+++ trunk/phase3/RELEASE-NOTES  2011-02-26 12:08:59 UTC (rev 82843)
@@ -142,7 +142,10 @@
 * (bug 15905) Nostalgia skin could become more usable by including a Talk:
   link at the top of the page
 * (bug 27560) Search queries no longer fail in walloon language
+* (bug 27679) Broken embedded files with special characters longer double HTML
+  escaped
 
+
 === API changes in 1.18 ===
 * (bug 26339) Throw warning when truncating an overlarge API result
 * (bug 14869) Add API module for accessing QueryPage-based special pages

Modified: trunk/phase3/includes/Linker.php
===================================================================
--- trunk/phase3/includes/Linker.php    2011-02-26 12:08:45 UTC (rev 82842)
+++ trunk/phase3/includes/Linker.php    2011-02-26 12:08:59 UTC (rev 82843)
@@ -686,10 +686,10 @@
         * Make a "broken" link to an image
         *
         * @param $title Title object
-        * @param $text String: link label
+        * @param $text String: link label in unescaped text form
         * @param $query String: query string
-        * @param $trail String: link trail
-        * @param $prefix String: link prefix
+        * @param $trail String: link trail (HTML fragment)
+        * @param $prefix String: link prefix (HTML fragment)
         * @param $time Boolean: a file of a certain timestamp was requested
         * @return String
         */
@@ -716,7 +716,7 @@
                                wfProfileOut( __METHOD__ );
                                return '<a href="' . htmlspecialchars( $href ) 
. '" class="new" title="' .
                                        htmlspecialchars( 
$title->getPrefixedText(), ENT_QUOTES ) . '">' .
-                                       htmlspecialchars( $prefix . $text . 
$inside, ENT_NOQUOTES ) . '</a>' . $trail;
+                                       "$prefix$text$inside</a>$trail";
                        } else {
                                wfProfileOut( __METHOD__ );
                                return $this->linkKnown( $title, 
"$prefix$text$inside", array(), $query ) . $trail;

Modified: trunk/phase3/tests/parser/parserTests.txt
===================================================================
--- trunk/phase3/tests/parser/parserTests.txt   2011-02-26 12:08:45 UTC (rev 
82842)
+++ trunk/phase3/tests/parser/parserTests.txt   2011-02-26 12:08:59 UTC (rev 
82843)
@@ -8422,6 +8422,28 @@
 </p>
 !! end
 
+!! test
+Special characters in embedded file links (bug 27679)
+!! input
+[[File:Contains & ampersand.jpg]]
+[[File:Does not exist.jpg|Title with & ampersand]]
+!! result
+<p><a 
href="/index.php?title=Special:Upload&amp;wpDestFile=Contains_%26_ampersand.jpg"
 class="new" title="File:Contains &amp; ampersand.jpg">File:Contains &amp; 
ampersand.jpg</a>
+<a href="/index.php?title=Special:Upload&amp;wpDestFile=Does_not_exist.jpg" 
class="new" title="File:Does not exist.jpg">Title with &amp; ampersand</a>
+</p>
+!! end
+
+!! test
+Special characters in embedded file links (bug 27679)
+!! input
+[[File:Contains & ampersand.jpg]]
+[[File:Does not exist.jpg|Title with & ampersand]]
+!! result
+<p><a 
href="/index.php?title=Special:Upload&amp;wpDestFile=Contains_%26_ampersand.jpg"
 class="new" title="File:Contains &amp; ampersand.jpg">File:Contains &amp; 
ampersand.jpg</a>
+<a href="/index.php?title=Special:Upload&amp;wpDestFile=Does_not_exist.jpg" 
class="new" title="File:Does not exist.jpg">Title with &amp; ampersand</a>
+</p>
+!! end
+
 TODO:
 more images
 more tables


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to