From 79181a321b0270c290922b3aa82fbd5244842075 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Fri, 26 May 2006 12:11:54 +0000 Subject: [PATCH] * Increase robustness of parser placeholders; fixes some glitches when adjacent to identifier-ish constructs such as URLs. * Shut up the parser test whining about files in a temp directory. --- RELEASE-NOTES | 3 +++ includes/Parser.php | 10 +++++++++- maintenance/parserTests.inc | 2 +- maintenance/parserTests.txt | 30 ++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 403c599d40..75dbe124eb 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -343,6 +343,9 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * Failed, but not zero-length, thumbnail renderings are now removed. Should help clean up when rsvg fails in weird ways. * (bug 6081) Change description for Turkmen language +* Increase robustness of parser placeholders; fixes some glitches when + adjacent to identifier-ish constructs such as URLs. +* Shut up the parser test whining about files in a temp directory. == Compatibility == diff --git a/includes/Parser.php b/includes/Parser.php index 549ba30461..7d4b1f874d 100644 --- a/includes/Parser.php +++ b/includes/Parser.php @@ -151,7 +151,15 @@ class Parser 'titles' => array() ); $this->mRevisionId = null; - $this->mUniqPrefix = 'UNIQ' . Parser::getRandomString(); + + /** + * Prefix for temporary replacement strings for the multipass parser. + * \x07 should never appear in input as it's disallowed in XML. + * Using it at the front also gives us a little extra robustness + * since it shouldn't match when butted up against identifier-like + * string constructs. + */ + $this->mUniqPrefix = "\x07UNIQ" . Parser::getRandomString(); # Clear these on every parse, bug 4549 $this->mTemplates = array(); diff --git a/maintenance/parserTests.inc b/maintenance/parserTests.inc index 0948eed0fb..77d601a7d2 100644 --- a/maintenance/parserTests.inc +++ b/maintenance/parserTests.inc @@ -520,7 +520,7 @@ class ParserTest { @rmdir( "$dir/thumb/3/39" ); # wtf? @rmdir( "$dir/thumb/3" ); @rmdir( "$dir/thumb" ); - rmdir( "$dir" ); + @rmdir( "$dir" ); } /** diff --git a/maintenance/parserTests.txt b/maintenance/parserTests.txt index f2fa9c235a..234c5f40ac 100644 --- a/maintenance/parserTests.txt +++ b/maintenance/parserTests.txt @@ -4115,6 +4115,36 @@ blah" onmouseover="alert('hello world');" align="left"MOVE MOUSE CURSOR OVER !! end +!!test +Fuzz testing: URL adjacent extension (with space, clean) +!! options +!! input +http://example.com junk +!! result +

http://example.com junk +

+!!end + +!!test +Fuzz testing: URL adjacent extension (no space, dirty; nowiki) +!! options +!! input +http://example.comjunk +!! result +

http://example.comjunk +

+!!end + +!!test +Fuzz testing: URL adjacent extension (no space, dirty; pre) +!! options +!! input +http://example.com
junk
+!! result +http://example.com
junk
+ +!!end + # # # -- 2.20.1