Commit graph

460 commits

Author SHA1 Message Date
Robin Pepermans
4ae1ef34c1 Per r90858 CR, throw MW exception on missing title context 2011-09-07 04:05:37 +00:00
Aaron Schulz
9d572d1844 Cleanup to r84610 per CR: changed BeforeParserMakeImageLinkObj hook to use a RepoGroup style param array that also excepts a 'broken' parameter. This new parameter replaces the odd "use timestamp '0' to make a broken thumbnail' convention. No other callers are using this hook other than FR, so the old time/sha1 params where removed. 2011-09-06 18:11:53 +00:00
Tim Starling
76f3bb9227 Reverted r84357 and r90461 and fixed the bug in a better way: in an empty document, consider section zero to exist, and to be empty, effectively representing the whole document. This allows section zero of a blank page to be viewed and edited with no updates to EditPage. 2011-09-05 06:56:08 +00:00
Aaron Schulz
6c34627a63 Reverted parser bump from r84601 per CR 2011-09-02 23:14:08 +00:00
Sam Reed
44020e254c Merge the iwtransclusion branch back into trunk
Hexmode fixed broken unit tests in revisions after last time
2011-08-24 13:03:03 +00:00
Brian Wolff
e15cb2b9db Follow-up r86534 - Do not add tracking categories if we're looking at a special page.
Thank you Nikerabbit for suggesting how to fix.
2011-08-21 18:46:01 +00:00
Roan Kattouw
b4ae56dea1 Per r90849, factor out most of the code that's duplicated between Parser::getExternalLinkAttribs() and Skin::addToSidebarPlain() into wfMatchesDomainList(). Change a loose comparison to a strict one, and add a FIXME comment about how whitelisting nl.wikipedia.org also whitelists nds-nl.wikipedia.org due to the function's simplistic substring approach. 2011-08-20 10:18:09 +00:00
Brian Wolff
c909720031 Follow-up r94680 - fix unit tests.
The way the magic variable unit tests are run looks a little sketchy to me...
2011-08-17 00:46:58 +00:00
Robin Pepermans
4948e56719 Magic words (time and number-formatting ones, plus DIRECTIONMARK, but not NAMESPACE) now depend on the page content language instead of the site language. In theory this sets the right magic words in system messages, although they are not used there.
Useful for multilingual wikis like Incubator, and probably for extensions like Translate.
2011-08-16 19:29:52 +00:00
Roan Kattouw
48bbe8b848 (bug 30269) Strings like foobar//barfoo are linked to become foobar[//barfoo]
* Introduce a boolean parameter to wfUrlProtocols() which, if set to false, will cause '//' to be dropped from the returned regex so it doesn't match protocol-relative URLs
* Introduce wfUrlProtocolsWithoutProtRel() as a wrapper for wfUrlProtocols( false ). The latter should not be used directly because the former is much clearer
* Use this new function in Parser::doMagicLinks() to fix the original bug. Also use it in ApiFormatBase::formatHTML() and CodeCommentLinker::link(), which probably had similar bugs
2011-08-15 12:20:00 +00:00
Alexandre Emsenhuber
76478abafe Added Parser::recursivePreprocess(); like preprocess() but doesn't call startParse() so that it can be used inside a parse operation using the same context without having to mess with other functions
Simple use case (PHP 5.3+) that will work show the expand text passed to a <preprocess> tag:
$wgHooks['ParserFirstCallInit'][] = function( $parser ) {
	$parser->setHook( 'preprocess', function( $text, $attr, $parser, $frame ) {
		return $parser->recursivePreprocess( $text, $frame );
	} );
	return true;
};
2011-08-14 20:22:52 +00:00
Roan Kattouw
7e13964a02 (bug 30236) Links like [[//example.com Link text]] were parsed as an internal link rather than an external link surrounded by brackets, like [[http://example.com Link text]]. Was caused by another pointless \b directly preceding wfUrlProtocols() in a regex. Also add a parser test for the [[http://example.com Link text]] case (the existing test only covered [[http://example.com]]) and add protocol-relative counterparts for both tests. 2011-08-12 13:32:06 +00:00
Robin Pepermans
a2ea0dcae0 remove stuff accidentally committed in r94279 2011-08-11 20:03:53 +00:00
Robin Pepermans
165519fdf5 * CategoryPage.php: fix the "category-empty" message per comment on r91518, it was outside the bodyContent. And do not convert interface text.
* Parser.php: Apparently that was a much bigger bug: do not convert interface text going through the parser either.
* Preferences.php: Do not convert the user signature.
For this bug in action, see e.g. http://sr.wikipedia.org/sr-ec/Посебно:Подешавањ?uselang=en (e.g. "Username" -> "Усернаме")
2011-08-11 19:58:23 +00:00
Alexandre Emsenhuber
759707959c We have startParse() for that 2011-08-11 13:57:15 +00:00
Sam Reed
3023c3053a Add documentation
Minor whitespace/brace additions
2011-08-05 00:33:03 +00:00
Sam Reed
8e062ead64 * (bug 17119) class Parser: senseless use of non-existing regexp back reference
Patch made by Dan Collins,, based on text placed by "seth"
2011-08-04 22:20:52 +00:00
Alexandre Emsenhuber
93075f0af3 Per Platonides, follow-up r93758: rename ParserOutput::addOutputPage() to ParserOutput::addOutputPageMetadata() to match its behaviour 2011-08-02 16:31:22 +00:00
Platonides
76e7c63bff Follow up r93633. Allow only classic spaces. 2011-08-02 16:23:46 +00:00
Alexandre Emsenhuber
700aec3775 * (bug 15558) Allow includable special pages to be parameterized using wiki syntax
* Changed SpecialPageFactory::capturePath() to take the same parameters as SpecialPageFactory::executePath() (except the last one) and made it always return a bool instead of bool-or-string. The result HTML can be fetched from the OutputPage object of the context.
* Added module styles, scritps and messages members to ParserOutput in addition to modules. The first one is needed to display Special:RecentChanges correctly when transcluded since EnhancedChangesList::beginRecentChangesList() calls addModuleStyles( 'mediawiki.special.changeslist' )

Yes, this means that you can use {{Special:Recentchanges|enhanced=0}} to use the old changes list. For the ones that wonder, {{Special:Recentchanges|uselang=something}} will not work since the Language object is forced to the one used by the parser.
2011-08-02 15:40:03 +00:00
Mark A. Hershberger
507edf6873 Fixes Bug #30149 - Handling of parentheses for Korean, Chinese and Japanese
Adapts the pipe trick with parens for fullwidth parentheses.  Adds parsertests.

Patch from Dan Collins.
2011-08-01 17:37:25 +00:00
Sam Reed
183d2dab37 Back out r93533, r93531, r93530
Breaks unit tests as below, not going to be able to fix them before I disappear for the evening, so might aswell leave trunk clean

ArticleTablesTest testbug14404

Error:
ArticleTablesTest::testbug14404
Undefined offset: 0

/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/includes/ArticleTablesTest.php:31
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiTestCase.php:60
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiPHPUnitCommand.php:20
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/phpunit.php:60

ParserTests testParserTest #552 - testParserTest with data set #551

Failure:
ParserTests::testParserTest with data set #551 ('RAW magic word', '{{RAW:QUERTY}}', '<p><a href="/index.php?title=Template:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:QUERTY (page does not exist)">Template:QUERTY</a>
</p>', '', '')
RAW magic word
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-<p><a href="/index.php?title=Template:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:QUERTY (page does not exist)">Template:QUERTY</a>
+<p><a href="/index.php?title=Template:RAW:QUERTY&amp;action=edit&amp;redlink=1" class="new" title="Template:RAW:QUERTY (page does not exist)">Template:RAW:QUERTY</a>
 </p>

/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/includes/parser/NewParserTest.php:545
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiTestCase.php:60
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/MediaWikiPHPUnitCommand.php:20
/home/ci/cruisecontrol-bin-2.8.3/projects/mw/source/tests/phpunit/phpunit.php:60
2011-07-30 15:56:54 +00:00
Sam Reed
dc9d39887e Merge iwtransclusion branch into trunk 2011-07-30 15:30:01 +00:00
Antoine Musso
176f91596c Unicode space separator characters (Zs) now terminates links
Fix 19052 which was only reporting the issue for U+3000 IDEOGRAPHIC SPACE.
Covers both external links and images links. See parser tests for examples.

Unicode 'Zs' includes all characters from the 'separator, space' category.
Characters part of this category are:

Char    Name
U+0020  SPACE
U+00A0  NO-BREAK SPACE
U+1680  OGHAM SPACE MARK
U+180E  MONGOLIAN VOWEL SEPARATOR
U+2000  EN QUAD
U+2001  EM QUAD
U+2002  EN SPACE
U+2003  EM SPACE
U+2004  THREE-PER-EM SPACE
U+2005  FOUR-PER-EM SPACE
U+2006  SIX-PER-EM SPACE
U+2007  FIGURE SPACE
U+2008  PUNCTUATION SPACE
U+2009  THIN SPACE
U+200A  HAIR SPACE
U+202F  NARROW NO-BREAK SPACE
U+205F  MEDIUM MATHEMATICAL SPACE
U+3000  IDEOGRAPHIC SPACE


TEST PLAN:

$ php parserTests.php --quiet
This is MediaWiki version 1.19alpha (r93258).

Reading tests from "tests/parser/parserTests.txt"...
Reading tests from "tests/parser/extraParserTests.txt"...
Reading tests from "../mwexts/LabeledSectionTransclusion/lstParserTests.txt"...
Passed 686 of 686 tests (100%)... ALL TESTS PASSED!

Sounds good :-)
2011-07-27 18:03:01 +00:00
Sam Reed
896f05efde Trim trailing whitespace
Add documentation

Remove unused variables

Remove an extract from ImageFunctionsTest
2011-07-24 21:36:04 +00:00
Ian Baker
64a8dd2094 Refactored section assembly code to be more readable
Added a hook that's called for each section.  This allows sections to be addressed separately at the document level, for example by wrapping each in a div (as in the reverted r50769).  This in-turn enables richer section-specific UI, like highlighting or in-line editing.
2011-07-18 23:23:14 +00:00
Roan Kattouw
ec7101610c Fix r14202 (!!): this validates the protocol against the regex for the second time (preg_split has already made sure it matches wfUrlProtocols() so no need), and uses strpos() to validate against a regex (that's just wrong). I'm removing it not because it's useless but because it breaks for URL protocols that don't contain a ':' ('//' in my case) for no reason at all. Found out about this when writing parser tests for it (will commit these in a minute), so yay tests! 2011-07-12 20:55:05 +00:00
Bryan Tong Minh
e9e0bf8cc1 Follow-up r88054: register the file if a hook changed the target file. 2011-07-09 10:31:09 +00:00
Roan Kattouw
4b36056ac9 (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. 2011-07-07 18:26:24 +00:00
Platonides
66f193da79 $wgContLang no longer used here 2011-06-29 13:23:51 +00:00
Robin Pepermans
6bc8739f6f Follow-up r90742: the parser should call getFunctionLang() 2011-06-27 23:58:46 +00:00
Robin Pepermans
d761eab349 Make parser->getFunctionLang be dependent on title->getPageLanguage() instead of $wgContLang, i.e. the page content language instead of the wiki content language. This sets the right language on page view + edit for all pages, instead of only edit preview on MediaWiki namespace pages (as in EditPage.php). 2011-06-26 22:58:27 +00:00
Robin Pepermans
9f9047290f Directionality and language improvements as part of bug 6100 (under $wgBetterDirectionality):
* Make TOC numberings be in the page content language instead of wiki content language.
* Update getPageLanguage() and add a hook (for bug 9360/28970).
* Show redirects (when viewing a page with &redirect=no) in the user language direction (not essential but nicer imo).
2011-06-24 22:10:39 +00:00
Aaron Schulz
335b921b2b * Removed break in first loop of generateTableHTML(), which caused:
'<b>Notice</b>: Undefined index: type in <b>C:\wamp\www\MW_trunk\includes\parser\Parser.php</b>
* Made some code simplifications
2011-06-24 20:25:16 +00:00
Sam Reed
1682c80f1f Followup r85596, recursiveTagParse returns a string, not a parser output object 2011-06-23 09:26:48 +00:00
Alexandre Emsenhuber
44574b23b0 Removed hidden usage of $wgTitle in parser and the workarround in ExtraParserTest.php 2011-06-22 17:45:31 +00:00
Sam Reed
ee5922ccf6 Expand return documentation for r84357 2011-06-20 13:57:22 +00:00
Sam Reed
16842c0b73 Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits (2/3), so hopefully reviewable in CR...
2011-06-17 16:05:05 +00:00
Alexandre Emsenhuber
e976326343 Per Nikerabbit, fixes for r89176:
* correct variable name in preprocessorFuzzTest.php
* Added type hints in Parser's test methods
2011-06-14 15:08:52 +00:00
Alexandre Emsenhuber
6582de54f3 Replace the text directly instead of using the StripState object since it will be unstripped just after the call replaceTransparentTags(), but left the call unstripGeneral() for the benefit of Poem extension that use it to escape the <br /> tag 2011-06-05 19:37:08 +00:00
Brion Vibber
443366b11b Provisional revert of r89230: per CR, benchmarking currently shows that it makes things slightly slower, not faster
http://www.mediawiki.org/wiki/Special:Code/MediaWiki/89230#c17571
2011-06-03 22:27:38 +00:00
Krinkle
439a38eca2 typo from r78201 2011-06-03 01:04:24 +00:00
Platonides
f5f020c3aa The big regex at doMagicLinks deserves being more thoroughly studied. 2011-05-31 21:52:39 +00:00
Jeroen De Dauw
8dc1a86b0c this method should not be private? the parser function docs use it as public 2011-05-31 17:19:11 +00:00
Tim Starling
67099169ad * Use Preprocessor_Hash by default in compiled mode, it is faster
* Don't profile MagicWord::get(), it is very fast and the profiling overhead was excessive. Profile MagicWord::load() instead.
2011-05-31 06:10:23 +00:00
Alexandre Emsenhuber
c58ef2b85b * make preprocessorFuzzTest.php pass the Title object to Parser, removed checks for non-object in Parser
* make the parser use ParserOptions::getUser() instead of $wgUser
* fixed some E_NOTICE and E_STRICT in preprocessorFuzzTest.php
2011-05-30 16:10:23 +00:00
Happy-melon
16ea3e3f82 Rv r84022 for now: crashes PHP on large url strings (bug29197), which is a nasty DOS vector. Leaving the parser tests in because this should definitely be fixed and reimplemented... 2011-05-29 09:32:17 +00:00
Sam Reed
3614ecfffb And more documentation. Yaaaay 2011-05-28 17:18:50 +00:00
Sam Reed
ebef5e723b More documentation tweaks/additions 2011-05-26 19:52:56 +00:00
Sam Reed
696100b6a9 Remove unused variables/globals
Swap while to foreach
2011-05-26 19:20:35 +00:00