Ensure abort link parsing on xmlish tag in link title position
authorArlo Breault <abreault@wikimedia.org>
Thu, 1 Mar 2018 18:59:43 +0000 (13:59 -0500)
committerArlo Breault <abreault@wikimedia.org>
Thu, 1 Mar 2018 19:08:24 +0000 (14:08 -0500)
This shouldn't be dependent on the current definition of legal title
chars and strip marker.

See the test "<nowiki> inside a link"

Change-Id: I0d87aca1bb0adf4ec5ac480e0373a65fcd150a72

includes/parser/Parser.php

index 2adfd0a..f6526ac 100644 (file)
@@ -2215,8 +2215,14 @@ class Parser {
                                $link = $origLink;
                        }
 
-                       $unstrip = $this->mStripState->unstripNoWiki( $link );
-                       $nt = is_string( $unstrip ) ? Title::newFromText( $unstrip ) : null;
+                       // \x7f isn't a default legal title char, so most likely strip
+                       // markers will force us into the "invalid form" path above.  But,
+                       // just in case, let's assert that xmlish tags aren't valid in
+                       // the title position.
+                       $unstrip = $this->mStripState->killMarkers( $link );
+                       $noMarkers = ( $unstrip === $link );
+
+                       $nt = $noMarkers ? Title::newFromText( $link ) : null;
                        if ( $nt === null ) {
                                $s .= $prefix . '[[' . $line;
                                continue;