From bf067d3395c6f9f96df87cf4cf43c3d4912fd53b Mon Sep 17 00:00:00 2001
From: Bryan Tong Minh
Date: Sat, 26 Feb 2011 12:08:59 +0000
Subject: [PATCH] (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
---
RELEASE-NOTES | 3 +++
includes/Linker.php | 8 ++++----
tests/parser/parserTests.txt | 22 ++++++++++++++++++++++
3 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index f6f8bdeba3..c19e677e39 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -142,6 +142,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
* (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
diff --git a/includes/Linker.php b/includes/Linker.php
index 568ac61bcf..08415171da 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -686,10 +686,10 @@ class Linker {
* 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 @@ class Linker {
wfProfileOut( __METHOD__ );
return '' .
- htmlspecialchars( $prefix . $text . $inside, ENT_NOQUOTES ) . '' . $trail;
+ "$prefix$text$inside$trail";
} else {
wfProfileOut( __METHOD__ );
return $this->linkKnown( $title, "$prefix$text$inside", array(), $query ) . $trail;
diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt
index a66f738078..c5063dc3e9 100644
--- a/tests/parser/parserTests.txt
+++ b/tests/parser/parserTests.txt
@@ -8422,6 +8422,28 @@ percent-encoding and + signs in internal links (Bug 26410)
!! end
+!! test
+Special characters in embedded file links (bug 27679)
+!! input
+[[File:Contains & ampersand.jpg]]
+[[File:Does not exist.jpg|Title with & ampersand]]
+!! result
+File:Contains & ampersand.jpg
+Title with & ampersand
+
+!! end
+
+!! test
+Special characters in embedded file links (bug 27679)
+!! input
+[[File:Contains & ampersand.jpg]]
+[[File:Does not exist.jpg|Title with & ampersand]]
+!! result
+File:Contains & ampersand.jpg
+Title with & ampersand
+
+!! end
+
TODO:
more images
more tables
--
2.20.1