* (bug 2374) Allow extension tags to be terminated empty elements
[lhc/web/wiklou.git] / includes / Parser.php
index 20f9fbb..a910afe 100644 (file)
@@ -197,8 +197,6 @@ class Parser
                        '/(.) (?=\\?|:|;|!|\\302\\273)/' => '\\1 \\2',
                        # french spaces, Guillemet-right
                        '/(\\302\\253) /' => '\\1 ',
-                       '/<hr *>/i' => '<hr />',
-                       '/<br *>/i' => '<br />',
                        '/<center *>/i' => '<div class="center">',
                        '/<\\/center *>/i' => '</div>',
                );
@@ -274,11 +272,14 @@ class Parser
                        $params = array( );
                }
 
+               // Hack to support short XML style tags
+               $text = preg_replace( "/<$tag(\\s+[^>]*|\\s*)\\/>/i", "<$tag\\1></$tag>", $text );
+               
                if( $tag == STRIP_COMMENTS ) {
                        $start = '/<!--()/';
                        $end   = '/-->/';
                } else {
-                       $start = "/<$tag([^>]*)>/i";
+                       $start = "/<$tag(\\s+[^>]*|\\s*)>/i";
                        $end   = "/<\\/$tag\\s*>/i";
                }
 
@@ -1435,7 +1436,13 @@ class Parser
                                $s .= $prefix . $sk->makeKnownLinkObj( $nt, $text, '', $trail );
                                continue;
                        }
-                       if ( $nt->isAlwaysKnown() ) {
+                       if( $nt->isLocal() && $nt->isAlwaysKnown() ) {
+                               /**
+                                * Skip lookups for special pages and self-links.
+                                * External interwiki links are not included here because
+                                * the HTTP urls would break output in the next parse step;
+                                * they will have placeholders kept.
+                                */
                                $s .= $sk->makeKnownLinkObj( $nt, $text, '', $trail, $prefix );
                        } else {
                                /**
@@ -2079,9 +2086,13 @@ class Parser
                        $mwMsgnw =& MagicWord::get( MAG_MSGNW );
                        if ( $mwMsgnw->matchStartAndRemove( $part1 ) ) {
                                $nowiki = true;
+                       } else {
+                               # Remove obsolete MSG:
+                               $mwMsg =& MagicWord::get( MAG_MSG );
+                               $mwMsg->matchStartAndRemove( $part1 );
                        }
 
-                       # int: is the wikitext equivalent of wfMsg()
+                       # Check if it is an internal message
                        $mwInt =& MagicWord::get( MAG_INT );
                        if ( $mwInt->matchStartAndRemove( $part1 ) ) {
                                if ( $this->incrementIncludeCount( 'int:'.$part1 ) ) {
@@ -2089,15 +2100,6 @@ class Parser
                                        $found = true;
                                }
                        }
-
-                       # msg: is the wikitext equivalent of wfMsgForContent()
-                       $mwMsg =& MagicWord::get( MAG_MSG );
-                       if ( $mwMsg->matchStartAndRemove( $part1 ) ) {
-                               if ( $this->incrementIncludeCount( 'msg:'.$part1 ) ) {
-                                        $text = $linestart . wfMsgReal( $part1, $args, true, true );
-                                        $found = true;
-                               }
-                       }
                }
 
                # NS
@@ -3103,9 +3105,10 @@ class Parser
         */
        function renderImageGallery( $text ) {
                # Setup the parser
-               global $wgUser, $wgParser, $wgTitle;
+               global $wgUser, $wgTitle;
                $parserOptions = ParserOptions::newFromUser( $wgUser );
-       
+               $localParser = new Parser();
+               
                global $wgLinkCache;
                $ig = new ImageGallery();
                $ig->setShowBytes( false );
@@ -3131,7 +3134,7 @@ class Parser
                                $label = '';
                        }
                        
-                       $html = $wgParser->parse( $label , $wgTitle, $parserOptions );
+                       $html = $localParser->parse( $label , $wgTitle, $parserOptions );
                        $html = $html->mText;
                        
                        $ig->add( new Image( $nt ), $html );