From 73649741ed1e2f557aec22a485598b199fdd2d09 Mon Sep 17 00:00:00 2001 From: Platonides Date: Wed, 5 May 2010 21:58:39 +0000 Subject: [PATCH] Recovered parser test whose content got broken in r12975, functionality broken in r14635. Changed what used to be EXT_LINK_TEXT_CLASS to define( 'EXT_LINK_TEXT_CLASS', '[^\]\\x00-\\x08\\x0a-\\x1F]' ); In plain English, do not allow control characters in description. We still allow tabs there, since they may arrive from a paste. We should probably make the space between the text and the description mandatory, it needs testing. These tests only work with the Hash Preprocessor, since the DOM Preprocessor changes them into the replacement character. Should we autolink an URL with a FFFD? That will require changing some regex into unicode ones. --- includes/DefaultSettings.php | 1 + includes/parser/Parser.php | 2 +- maintenance/ExtraParserTests.txt | Bin 0 -> 1261 bytes maintenance/parserTests.inc | 7 ++++--- maintenance/parserTests.txt | 12 ------------ 5 files changed, 6 insertions(+), 16 deletions(-) create mode 100644 maintenance/ExtraParserTests.txt diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 48254f61e2..8ea4d3d071 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -4015,6 +4015,7 @@ $wgAPICacheHelpTimeout = 60*60; */ $wgParserTestFiles = array( "$IP/maintenance/parserTests.txt", + "$IP/maintenance/ExtraParserTests.txt" ); /** diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 8a59b65bc0..7032b86b1e 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -129,7 +129,7 @@ class Parser { $this->mDefaultStripList = $this->mStripList = array(); $this->mUrlProtocols = wfUrlProtocols(); $this->mExtLinkBracketedRegex = '/\[(\b(' . wfUrlProtocols() . ')'. - '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x0a\\x0d]*?)\]/S'; + '[^][<>"\\x00-\\x20\\x7F]+) *([^\]\\x00-\\x08\\x0a-\\x1F]*?)\]/S'; $this->mVarCache = array(); if ( isset( $conf['preprocessorClass'] ) ) { $this->mPreprocessorClass = $conf['preprocessorClass']; diff --git a/maintenance/ExtraParserTests.txt b/maintenance/ExtraParserTests.txt new file mode 100644 index 0000000000000000000000000000000000000000..66b8032d183c56c5390c88e80f3dc1a676f904db GIT binary patch literal 1261 zcmc&zQESvd5WYv^?D^@-7gAiGz&q|p@T2H9HnX6$5fQLns7OlL(KHh@y#QqZ zIbA$xK^+}Udg^?XjyyVW*6-4pFx;ZE%^nJG-@h(s4%xC#%JbMc6(WVmno{DpxqR^Q z=>n4}cAY3HWF3B;5L=#mYw6F+RhiRSGc`bU9ZBnNRw|=xfkPq!H635E(O$7YW}JnPyUM? z_o@eWeDmWC-dH`QVkQ)S?!f%tSro#368?D*)WOU@ia^GCzXzqmpJrM%+Ul}`Pd~74 ZC_41bqlEwVTxG?-3;2vqN%z4_p8?XnuW$eW literal 0 HcmV?d00001 diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index 0a3522f236..2990944990 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -304,10 +304,10 @@ class ParserTest { /** * Get a Parser object */ - function getParser() { + function getParser($preprocessor = null) { global $wgParserConf; $class = $wgParserConf['class']; - $parser = new $class( $wgParserConf ); + $parser = new $class( array( 'preprocessorClass'=>$preprocessor ) + $wgParserConf ); foreach( $this->hooks as $tag => $callback ) { $parser->setHook( $tag, $callback ); } @@ -352,7 +352,8 @@ class ParserTest { $noxml = isset( $opts['noxml'] ); $local = isset( $opts['local'] ); - $parser = $this->getParser(); + $preprocessor = @$opts['preprocessor']; + $parser = $this->getParser( $preprocessor ); $title = Title::newFromText( $titleText ); $matches = array(); diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index c40e70982e..ade29b75d6 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -864,18 +864,6 @@ BUG 289: literal double quote in bracketed URL

!!end -!! test -External links: invalid character -Fixme: the missing char seems to have gone missing -!! options -disabled -!! input -[http://www.example.com test] -!! result -

[http://www.example.com test] -

-!! end - !! test External links: multiple legal whitespace is fine, Magnus. Don't break it please. (bug 5081) !! input -- 2.20.1