From: C. Scott Ananian Date: Wed, 28 Feb 2018 21:11:09 +0000 (-0500) Subject: Use `class="free external"` only on unbracketed URLs X-Git-Tag: 1.31.0-rc.0~432^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=65fcb7a94528ea56d461b3c7b9cb4d4fe4e99211;p=lhc%2Fweb%2Fwiklou.git Use `class="free external"` only on unbracketed URLs The ability for URLs to be marked free even if they use bracketed syntax but "sorta look free" (aka unbracketed) was added 13 years ago in 2d71cb30802e5cb78a423a1699ad87e23bfe9f4e (r7074). It seemed like a reasonable idea at the time: make printed output a little prettier by marking "sorta free" URLs as free. But this complicates the semantics of wikitext, and introduces all sorts of strange corner cases, for example: [http://example.com/& http://example.com/&] isn't marked as free, even though the parser output is: http://example.com/& This functionality isn't actually needed: if you want the pretty printed output of an unbracketed URL, then actually use an unbracketed URL. In recent years we're more concerned with simplifying the semantics of wikitext and eliminating corner cases, such that the content of our wikis can be effectively archived. The "effectively free" URLs are low-hanging fruit in this quest. Change-Id: I339e8698786c60c96a37a73443cb9a04362662c4 --- diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 83669e6fdc..718ada9be4 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -285,6 +285,8 @@ changes to languages because of Phabricator reports. * Parser::isValidHalfParsedText() * StripState::getSubState() * StripState::merge() +* The "free" class is now only applied to unbracketed URLs in wikitext. Links + written using square brackets will get the class "text" not "free". == Compatibility == MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is supported, diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8e5dcbdab1..945872887f 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -1868,8 +1868,8 @@ class Parser { $dtrail = ''; - # Set linktype for CSS - if URL==text, link is essentially free - $linktype = ( $text === $url ) ? 'free' : 'text'; + # Set linktype for CSS + $linktype = 'text'; # No link text, e.g. [http://domain.tld/some.link] if ( $text == '' ) { diff --git a/tests/parser/parserTests.txt b/tests/parser/parserTests.txt index 6da23e1c46..f98044b57c 100644 --- a/tests/parser/parserTests.txt +++ b/tests/parser/parserTests.txt @@ -4937,7 +4937,7 @@ parsoid=wt2html !! wikitext URL in text: [http://example.com http://example.com] !! html/php -

URL in text: http://example.com +

URL in text: http://example.com

!! html/parsoid

URL in text: http://example.com

@@ -22532,8 +22532,8 @@ gopher://www.google.com !! html/php

http://www.google.com gopher://www.google.com -http://www.google.com -gopher://www.google.com +http://www.google.com +gopher://www.google.com irc://www.google.com www.гоогле.цом/фтп://дир www.гоогле.цом