Unescape more "safe" characters when producing URLs, for added prettiness. Checked...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 8 Aug 2008 15:45:52 +0000 (15:45 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 8 Aug 2008 15:45:52 +0000 (15:45 +0000)
RELEASE-NOTES
includes/GlobalFunctions.php

index 5ac8a1e..42bedef 100644 (file)
@@ -57,6 +57,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   being converted or not
 * (bug 14921) Special:Contributions/: add user name to <title>
   Patch by Emufarmers
+* Unescape more "safe" characters when producing URLs, for added prettiness
 
 === Bug fixes in 1.14 ===
 
index cfdec5c..d70edbc 100644 (file)
@@ -151,16 +151,31 @@ function wfRandom() {
 }
 
 /**
- * We want / and : to be included as literal characters in our title URLs.
+ * We want some things to be included as literal characters in our title URLs
+ * for prettiness, which urlencode encodes by default.  According to RFC 1738,
+ * all of the following should be safe:
+ *
+ * ;:@&=$-_.+!*'(),
+ *
+ * But + is not safe because it's used to indicate a space; &= are only safe in
+ * paths and not in queries (and we don't distinguish here); ' seems kind of
+ * scary; and urlencode() doesn't touch -_. to begin with.  Plus, although /
+ * is reserved, we don't care.  So the list we unescape is:
+ *
+ * ;:@$!*(),/
+ *
  * %2F in the page titles seems to fatally break for some reason.
  *
  * @param $s String:
  * @return string
 */
-function wfUrlencode ( $s ) {
+function wfUrlencode( $s ) {
        $s = urlencode( $s );
-       $s = preg_replace( '/%3[Aa]/', ':', $s );
-       $s = preg_replace( '/%2[Ff]/', '/', $s );
+       $s = str_ireplace(
+               array( '%3B','%3A','%40','%24','%21','%2A','%28','%29','%2C','%2F' ),
+               array(   ';',  ':',  '@',  '$',  '!',  '*',  '(',  ')',  ',',  '/' ),
+               $s
+       );
 
        return $s;
 }