* (bug 12553) Fixed invalid XHTML in edit conflict screen
[lhc/web/wiklou.git] / includes / Title.php
index 3521360..4afa47f 100644 (file)
@@ -1188,8 +1188,7 @@ class Title {
                        }
                }
 
-               if ($action == 'protect')
-               {
+               if ($action == 'protect') {
                        if ($this->getUserPermissionsErrors('edit', $user) != array()) {
                                $errors[] = array( 'protect-cantedit' ); // If they can't edit, they shouldn't protect.
                        }
@@ -1218,32 +1217,32 @@ class Title {
                        }
                } elseif( $action == 'move' && !( $this->isMovable() && $user->isAllowed( 'move' ) ) ) {
                        $errors[] = $user->isAnon() ? array ( 'movenologintext' ) : array ('movenotallowed');
-                       } else if ( !$user->isAllowed( $action ) ) {
+               } else if ( !$user->isAllowed( $action ) ) {
                        $return = null;
                        $groups = array();
                        global $wgGroupPermissions;
-                       foreach( $wgGroupPermissions as $key => $value ) {
-                           if( isset( $value[$action] ) && $value[$action] == true ) {
-                               $groupName = User::getGroupName( $key );
-                               $groupPage = User::getGroupPage( $key );
-                               if( $groupPage ) {
-                                   $groups[] = '[['.$groupPage->getPrefixedText().'|'.$groupName.']]';
-                               } else {
-                                   $groups[] = $groupName;
-                               }
-                           }
-                       }
-                       $n = count( $groups );
-                       $groups = implode( ', ', $groups );
-                       switch( $n ) {
-                           case 0:
-                           case 1:
-                           case 2:
-                               $return = array( "badaccess-group$n", $groups );
-                               break;
-                           default:
-                               $return = array( 'badaccess-groups', $groups );
-                       }
+                       foreach( $wgGroupPermissions as $key => $value ) {
+                               if( isset( $value[$action] ) && $value[$action] == true ) {
+                                       $groupName = User::getGroupName( $key );
+                                       $groupPage = User::getGroupPage( $key );
+                                       if( $groupPage ) {
+                                               $groups[] = '[['.$groupPage->getPrefixedText().'|'.$groupName.']]';
+                                       } else {
+                                               $groups[] = $groupName;
+                                       }
+                               }
+                       }
+                       $n = count( $groups );
+                       $groups = implode( ', ', $groups );
+                       switch( $n ) {
+                               case 0:
+                               case 1:
+                               case 2:
+                                       $return = array( "badaccess-group$n", $groups );
+                                       break;
+                               default:
+                                       $return = array( 'badaccess-groups', $groups );
+                       }
                        $errors[] = $return;
                }
 
@@ -1894,8 +1893,18 @@ class Title {
                # Initialisation
                static $rxTc = false;
                if( !$rxTc ) {
-                       # % is needed as well
-                       $rxTc = '/[^' . Title::legalChars() . ']|%[0-9A-Fa-f]{2}/S';
+                       # Matching titles will be held as illegal.
+                       $rxTc = '/' .
+                               # Any character not allowed is forbidden...
+                               '[^' . Title::legalChars() . ']' .
+                               # URL percent encoding sequences interfere with the ability
+                               # to round-trip titles -- you can't link to them consistently.
+                               '|%[0-9A-Fa-f]{2}' .
+                               # XML/HTML character references produce similar issues.
+                               '|&[A-Za-z0-9\x80-\xff]+;' .
+                               '|&#[0-9]+;' .
+                               '|&#x[0-9A-Fa-f]+;' .
+                               '/S';
                }
 
                $this->mInterwiki = $this->mFragment = '';
@@ -2382,7 +2391,7 @@ class Title {
                }
                if( $u )
                        $u->doUpdate();
-               # Update message catch for interface messages
+               # Update message cache for interface messages
                if( $nt->getNamespace() == NS_MEDIAWIKI ) {
                        global $wgMessageCache;
                        $newarticle = new Article( $nt );