* (bug 13815) In the comment for page moves, use the colon-separator message instead...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 14 Jul 2008 21:43:27 +0000 (21:43 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Mon, 14 Jul 2008 21:43:27 +0000 (21:43 +0000)
* So that this works properly, don't escape HTML entities in edit summaries.  I don't see any good reason for them to be escaped there.  Of course, this may result in old edit summaries displaying slightly differently if for some reason they included an entity, but in that case there's at least a 50% chance that they intended it to not be escaped in the first place.

RELEASE-NOTES
includes/GlobalFunctions.php
includes/Linker.php
includes/Sanitizer.php
includes/Title.php

index 1e47f50..2217484 100644 (file)
@@ -186,6 +186,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   the database is potentially queried
 * (bug 9736) Redirects on Special:Fewestrevisions are now marked as such.
 * New date/time formats in Cs localization according to ČSN and PČP.
+* HTML entities like &nbsp; now work (are not escaped) in edit summaries.
+* (bug 13815) In the comment for page moves, use the colon-separator message
+  instead of a hardcoded colon.
  
 === Bug fixes in 1.13 ===
 
index 56a313f..d90c612 100644 (file)
@@ -628,9 +628,7 @@ function wfMsgExt( $key, $options ) {
        if ( in_array('escape', $options) ) {
                $string = htmlspecialchars ( $string );
        } elseif ( in_array( 'escapenoentities', $options ) ) {
-               $string = htmlspecialchars( $string );
-               $string = str_replace( '&amp;', '&', $string );
-               $string = Sanitizer::normalizeCharReferences( $string );
+               $string = Sanitizer::escapeHtmlAllowEntities( $string );
        }
 
        if( in_array('replaceafter', $options) ) {
index 03e7a9e..6f502cf 100644 (file)
@@ -1045,7 +1045,8 @@ class Linker {
 
                # Sanitize text a bit:
                $comment = str_replace( "\n", " ", $comment );
-               $comment = htmlspecialchars( $comment );
+               # Allow HTML entities (for bug 13815)
+               $comment = Sanitizer::escapeHtmlAllowEntities( $comment );
 
                # Render autocomments and make links:
                $comment = $this->formatAutoComments( $comment, $title, $local );
index 28b1c27..4d5b89c 100644 (file)
@@ -826,6 +826,22 @@ class Sanitizer {
                        $class ), '_');
        }
 
+       /**
+        * Given HTML input, escape with htmlspecialchars but un-escape entites.
+        * This allows (generally harmless) entities like &nbsp; to survive.
+        *
+        * @param  string $html String to escape
+        * @return string Escaped input
+        */
+       static function escapeHtmlAllowEntities( $html ) {
+               # It seems wise to escape ' as well as ", as a matter of course.  Can't
+               # hurt.
+               $html = htmlspecialchars( $html, ENT_QUOTES );
+               $html = str_replace( '&amp;', '&', $html );
+               $html = Sanitizer::normalizeCharReferences( $html );
+               return $html;
+       }
+
        /**
         * Regex replace callback for armoring links against further processing.
         * @param array $matches
index b64d2c9..d0b593c 100644 (file)
@@ -2718,7 +2718,9 @@ class Title {
                $fname = 'MovePageForm::moveToNewTitle';
                $comment = wfMsgForContent( '1movedto2', $this->getPrefixedText(), $nt->getPrefixedText() );
                if ( $reason ) {
-                       $comment .= ": $reason";
+                       $comment .= wfMsgExt( 'colon-separator',
+                               array( 'escapenoentities', 'content' ) );
+                       $comment .= $reason;
                }
 
                $newid = $nt->getArticleID();