From: Roan Kattouw Date: Thu, 7 Jul 2011 18:26:24 +0000 (+0000) Subject: (bug 29497) To support protocol-relative URLs in external links, add '//' to $wgUrlPr... X-Git-Tag: 1.31.0-rc.0~29005 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=4b36056ac95f848e1d4ca688414e6e1ca7fd6467;p=lhc%2Fweb%2Fwiklou.git (bug 29497) To support protocol-relative URLs in external links, add '//' to $wgUrlProtocols and remove a useless \b in the bracketed external link regex in the parser that prevented the former from working outright. With this change, things like [//example.com/wiki/Foo Bar] are now supported, and [[{fullurl:Foo|action=edit}} Bar] no longer breaks if $wgServer is set to '//example.com' but produces a protocol-relative link instead. Protocol-relative URLs in free text are not picked up and turned into [1] links like URLs with protcols are; this is probably due to another \b somewhere, but I think this is a good thing. --- diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index e5b05f9514..e6b02f860a 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -2790,6 +2790,7 @@ $wgUrlProtocols = array( 'svn://', 'git://', 'mms://', + '//', // for protocol-relative URLs ); /** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 39637bf246..6227ac3cfe 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -183,7 +183,7 @@ class Parser { public function __construct( $conf = array() ) { $this->mConf = $conf; $this->mUrlProtocols = wfUrlProtocols(); - $this->mExtLinkBracketedRegex = '/\[(\b(' . wfUrlProtocols() . ')'. + $this->mExtLinkBracketedRegex = '/\[((' . wfUrlProtocols() . ')'. '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S'; if ( isset( $conf['preprocessorClass'] ) ) { $this->mPreprocessorClass = $conf['preprocessorClass'];