Merge "Revert "Fix link prefix/suffixes around Category and Language links.""
[lhc/web/wiklou.git] / includes / parser / Parser.php
index 57e627e..988e248 100644 (file)
@@ -2296,11 +2296,8 @@ class Parser {
                                                $this->mOutput->addLanguageLink( $nt->getFullText() );
                                        }
 
-                                       /**
-                                        * Strip the whitespace interwiki links produce, see T10897
-                                        */
                                        $s = rtrim( $s . $prefix );
-                                       $s .= rtrim( $trail, "\n" );
+                                       $s .= trim( $trail, "\n" ) == '' ? '' : $prefix . $trail;
                                        continue;
                                }
 
@@ -2325,11 +2322,7 @@ class Parser {
                                                continue;
                                        }
                                } elseif ( $ns == NS_CATEGORY ) {
-                                       /**
-                                        * Strip the whitespace Category links produce, see T2087
-                                        */
-                                       $s = rtrim( $s . $prefix ); # T2087, T87753
-                                       $s .= rtrim( $trail, "\n" );
+                                       $s = rtrim( $s . "\n" ); # T2087
 
                                        if ( $wasblank ) {
                                                $sortkey = $this->getDefaultSort();
@@ -2341,6 +2334,11 @@ class Parser {
                                        $sortkey = $this->getConverterLanguage()->convertCategoryKey( $sortkey );
                                        $this->mOutput->addCategory( $nt->getDBkey(), $sortkey );
 
+                                       /**
+                                        * Strip the whitespace Category links produce, see T2087
+                                        */
+                                       $s .= trim( $prefix . $trail, "\n" ) == '' ? '' : $prefix . $trail;
+
                                        continue;
                                }
                        }