From 07650eba1d0125a615d4d0dd69f171fd416f1d7e Mon Sep 17 00:00:00 2001
From: Brion Vibber
Date: Sun, 30 Jan 2005 04:11:22 +0000
Subject: [PATCH] * (bug 1228) Fix double-escaping on & sequences in
[enclosed] URLs
---
includes/Parser.php | 5 +++++
maintenance/parserTests.txt | 27 +++++++++++++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/includes/Parser.php b/includes/Parser.php
index 1f1701e197..3ed672bbdf 100644
--- a/includes/Parser.php
+++ b/includes/Parser.php
@@ -1015,6 +1015,11 @@ class Parser
}
}
+ # Replace & from obsolete syntax with &.
+ # All HTML entities will be escaped by makeExternalLink()
+ # or maybeMakeImageLink()
+ $url = str_replace( '&', '&', $url );
+
# Process the trail (i.e. everything after this link up until start of the next link),
# replacing any non-bracketed links
$trail = $this->replaceFreeExternalLinks( $trail );
diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt
index 79a6afddf5..47656ef6ba 100644
--- a/maintenance/parserTests.txt
+++ b/maintenance/parserTests.txt
@@ -480,6 +480,33 @@ Old & use: http://x&y
!! end
+!! test
+External links: encoded ampersand
+!! input
+Old & use: http://x&y
+!! result
+Old & use: http://x&y
+
+!! end
+
+!! test
+External links: [raw ampersand]
+!! input
+Old & use: [http://x&y]
+!! result
+Old & use: [1]
+
+!! end
+
+!! test
+External links: [encoded ampersand]
+!! input
+Old & use: [http://x&y]
+!! result
+Old & use: [1]
+
+!! end
+
!! test
External links: www.jpeg.org (bug 554)
!! input
--
2.20.1