Commit graph

512 commits

Author SHA1 Message Date
umherirrender
b5511c68c3 (bug 34355) add a variable and parser function for the namespace number
Change-Id: Ie162cfda7ddd38d4278ceee5fd23f5a4e579cb96
2012-04-03 13:25:06 -07:00
Daniel Friesen
e2ee009e5c Commit the cryptrand project worked on in git:
- MWCryptRand: A new api for generating cryptographic randomness for security tokens. Uses whatever cryptographic source is available and if not falls back to using random state and clock drift.
- wfRandomString - A simple non-cryptographic pesudo-random string generation function to replace wfGenerateToken which was written pretending to be secure when it's really not.
- Core updates to use MWCryptRand in various places:
-- user_token generation (to do this we stop generating user_token implicitly and only generate it when needed to avoid depleting the system's entropy pool by reading random data we'll never use)
-- email confirmation token generation
-- password salt generation
-- temporary password generation
-- Generation of the automatic watchlist token
-- login and create user tokens
-- session ids when php's entropy sources are not set
-- the installer when generating wgSecretKey and the upgrade key
2012-03-20 05:17:40 +00:00
Tim Starling
13b514edae Fixed a few "strip tag exposed" bugs.
* Introduced Parser::killMarkers() based on the concept from StringFunctions. Used it in cases where markerStripCallback() doesn't make sense semantically, namely grammar, padleft, padright and anchorencode. Used markerStripCallback() in other cases.
* Changed headline unstrip order as suggested by P.Copp on bug 18295
* In CPF::lc() and CPF::uc(), removed the is_callable(). This was a temporary testing hack committed by me in r30109, which allowed me to do differential testing against a copy of the parser from before that revision.
2012-03-20 04:39:09 +00:00
Sam Reed
daa4e524b7 More occurrence typos 2012-03-19 21:40:39 +00:00
Tim Starling
f15a91f293 In the $clearState=true case, remove strip marker prefixes from the Parser::parse() input. It's only possible for strip markers to be present in this case if the caller manages to guess the output of Parser::getRandomString() in advance. Even if that is possible, it's not recommended as a robust calling procedure.
Also cleaned up some old commented-out code in this area.
2012-03-16 00:29:26 +00:00
Max Semenik
083d47cc73 (bug 23795) Add parser itself to ParserMakeImageParams hook. 2012-03-09 18:32:03 +00:00
Robin Pepermans
b539f7a98e Follow-up r112479
* Add @since, fix indentation.
* Change default from 'all' to 'mw' as it's the most used (so default fetchLanguageNames() is equivalent to default getLanguageNames()).
* Add the include parameter also to fetchLanguageName() as it's needed in Parser: interlanguage links should only take into account mediawiki names. (Doesn't make a difference with how the functions are now, but could have been later.)
2012-03-08 19:30:30 +00:00
Tim Starling
561424c266 Transitional patch for bug 34832: introduce a CI-style option to allow deployment of 1.19 to converter wikis without disruption. The bug fix can be rolled out later by setting $wgBug34832TransitionalRollback = false. This is meant as a temporary measure, while we figure out a way to properly support Chinese wikis for inclusion in the 1.19 tarball.
Introduce a global variable which causes language conversion to not be disabled in interface messages (as before r94279). Use $wgContLang for conversion (as before r97849) since $wgContLang is set to the base language (e.g. zh) on converter wikis, whereas a typical user language (e.g. zh-tw) only has a FakeConverter.
2012-03-05 12:14:53 +00:00
Tim Starling
7df3473cfe * Fix for r41340, r96405, r97849: introduce a function which gets the current content language, called Parser::getTargetLanguage() following the ParserOptions terminology, and added doc comments, to improve the chances of a human being able to work out what is going on. Just because a function happens to do the thing you want doesn't mean you should call it.
* The language object used for lc() in Parser::braceSubstitution() must match the one used in setFunctionHook() during firstCallInit(). It can't change depending on what message you are parsing. Use $wgContLang like before r97849.
2012-03-05 05:53:12 +00:00
Sam Reed
2ec09c5165 More return documentation 2012-02-09 21:35:05 +00:00
Sam Reed
0a626db6e1 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 19:29:36 +00:00
Sam Reed
85bbb0b080 Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 18:01:10 +00:00
Sam Reed
f3cc77aaee Fixing some of the "@return true" or "@return false", need to be "@return bool" and then the metadata can say true if foo, false if bar
Other documentation improvements
2012-02-09 17:41:50 +00:00
Platonides
49e6e233ec Bug 33845: Headings become cursive in TOC when they contain an image
Fixes the problems with r102179 and r102179, as there are
valid tags which begin the same, which meant they were not removed from
the TOC (the second regex, intended to remove tag parameters, then converted
<img or <blockquote> into <i> / <b>).
The same problem existed in the original regex, but as there are no valid 
tags which begin with sup or sub, it never happened).

Added comment explaining the tocline regex, and added a bunch of parser tests.
2012-01-21 16:27:27 +00:00
Max Semenik
b7e7a6c76e Made Parser::addTrackingCategory() public to benefit tag hooks/parser functions developers 2012-01-11 15:42:29 +00:00
Niklas Laxström
0865348cd4 Missing @since tags have a yet another victim 2012-01-09 19:11:55 +00:00
Sam Reed
7632e4a26f * (bug 33525) clearTagHooks doesn't clear function hooks.
* (bug 33523) Function tag hooks don't appear on Special:Version.

Patches by Nikola Kovacs
2012-01-04 21:30:06 +00:00
Antoine Musso
f6df3e972d revert r107006
(bug 23427) Introduced {{PAGEID}} variable to expose page.page_id
[patch by Waldir]
2012-01-04 09:08:16 +00:00
Brian Wolff
770cd71b51 (bug 31469) Make sure tracking category messages expand variables like
{{NAMESPACE}} relative to the Title of the currently being parsed page.

Basically wfMsgForContent expands messages with wrong title while doing linksupdate stuff via job queue. For the broken file tracking category (r86534),Wikipedia folk want to sort the page into different categories based on namespace, and for some namespaces not categorize them at all (After all, a broken file link in a talk namespace is often not a bad thing).

Anyhow, explicitly set the title object for the message using wfMessage. There's probably deeper issues here in regards to why wfMsg et al is using wrong title, but this should fix the immediate issue.
2011-12-30 06:44:38 +00:00
Danny B
ff2ef8285a * (bug 23427) Introduced {{PAGEID}} variable to expose page.page_id [patch by Waldir] 2011-12-21 23:19:24 +00:00
Brian Wolff
4df8e9d595 Throw an exception if Parser::disableCache is called before mOutput initialized (Aka when not parsing something).
So far I've encountered 2 extensions that give fatal errors from calling $wgParser->disableOutput() from hooks that are called at points where parsing is not taking place! Exception with a backtrace is much nicer than "Fatal error: Call to a member function disableCache() on a non-object..."
2011-12-15 07:17:29 +00:00
Jeroen De Dauw
4544a78316 rem use of escapeLocalURL 2011-12-13 04:58:48 +00:00
Tim Starling
71e27e22de * Revert r103476, r105161 and implement the fix for bug 32858 (a.k.a. bug 32450) in WikiPage instead. See comment 14 for further rationale.
* Clarified release notes. Please write what the new code does, not the bug description.
2011-12-09 10:32:55 +00:00
Chad Horohoe
a1f5c6ce73 Minor tweaks to cleanSig(inSig)
* Make cleanSig public, since it's a declared entry point per class docs
* Make cleanSigInSig public static, added 2 more test cases for it
2011-12-06 23:07:13 +00:00
Antoine Musso
144ffcc01a allow bold in TOC lines
just like r102179 allowed italics in TOC lines for bug 26375, this
patch allow bold text as well.
2011-12-06 10:50:47 +00:00
Antoine Musso
7fc6a7aae0 Skip replaceInternalLinks2 for js/css pages
Just skip the whole replaceInternalLinks2 parser function whenever we hit
js/css pages. Previous patch r103476 only handled Category links which was
not enough.
2011-12-05 10:14:40 +00:00
John Du Hart
51a6eadec1 Followup r103817, updating setLang usages 2011-11-23 10:28:21 +00:00
Antoine Musso
78562bd14c (bug 32450) MediaWiki: .js|.css pages parsed [[Category:#]] links
This patch skip the [[Category:#]] parsing logic when the Title is in
NS_MEDIAWIKI and ends with .js or .css. This way the code is kept as is
and pages are no more categorized.

How to reproduce the issue:

	$ echo 'var foo = "[[Category:bug32450]]"' \
	| php maintenance/parse.php --title MediaWiki:Foobar.js
	<p>var foo = ""
	</p>
	$

Note how the text got stripped.

After this patch:

	$ echo 'var foo = "[[Category:bug32450]]"' \
	| php maintenance/parse.php --title MediaWiki:Foobar.js
	<p>var foo = "[[Category:bug32450]]"
	</p>
	$

TEST PLAN:
==========

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

Reading tests from "tests/parser/parserTests.txt"...
Reading tests from "tests/parser/extraParserTests.txt"...
Passed 654 of 654 tests (100%)... ALL TESTS PASSED!
$
2011-11-17 16:46:45 +00:00
Platonides
528a450f68 Attempt to fix translatewiki bug 32057
The different Preprocessor::newChild expect false (with strict comparison) if there's no title passed to them.
2011-11-08 20:58:57 +00:00
Platonides
c77380f9c2 Bug 26375 - Italics should be passed to TOC
http://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28technical%29&oldid=403630551#Italics_in_ToC
2011-11-06 15:07:34 +00:00
Aaron Schulz
6c4360c951 Make use of Title::isSpecialPage() in various places 2011-11-02 20:55:08 +00:00
Aaron Schulz
7377d6c080 Added pfunc profiling to braceSubstitution() 2011-10-27 21:53:37 +00:00
Platonides
d581e9dd5a Removal of unused globals 2011-10-27 20:48:09 +00:00
Aaron Schulz
9a932c4bc8 Fixed braceSubstitution() to only profile templates rather than all kinds of possibly long strings of text to parse. It was dumping the whole text as the name of the profiling entry. 2011-10-27 01:19:34 +00:00
Platonides
8d0c01d751 If the page contains __NOEDITSECTION__, it will never have edit sections, so don't create markers. Follow-up r99250.
Fix for bug 31647: Regression: __NOEDITSECTION__ is ignored when the page is read from the parser cache
2011-10-25 22:18:33 +00:00
Alexandre Emsenhuber
0ba7a5f510 * (bug 31921) Fix for r78201: magic words REVISIONDAY, REVISIONMONTH and REVISIONYEAR now give current values on preview 2011-10-24 16:14:49 +00:00
Alexandre Emsenhuber
d491ae56a7 Follow-up r100227:
* Missed one call to ParserOptions::getUserLang() in Parser
* Also convert RefreshLinksJob and RefreshLinksJob2 to use ParserOptions::newFromUserAndLang() and pass $wgContLang instead of whatever $wgLang could be
2011-10-19 15:30:02 +00:00
Alexandre Emsenhuber
bd548f36e9 * Changed ParserOptions to store a Language object instead of only a string, avoids object -> string -> object conversion
* ParserOptions::getUserLang() will still return a string for compatibility, added ParserOptions::getUserLangObj() to get the object
* Added ParserOptions::newFromUserAndLang() and ParserOptions::newFromContext() to easily get a ParserOptions object when a context is available or when someone wants to force the language
* Updated OutputPage and Preferences to use newFromContext() and WikiPage to use newFromUserAndLang()
* ParserOptions::setUserLang() still accepts either a string or a Language object, but changed the calls to pass an object instead of a string
* Changed Parser::getFunctionLang() to return the Language object from ParserOptions when parsing interface messages rather than $wgLang directly and updated the documentation to say that $wgLang should not be used directly (as $wgUser, $wgTitle and $wgRequest)
2011-10-19 14:16:01 +00:00
Platonides
4d065bb19f Bug 31445: "Section edit links do not show"
Always generate the mw:editsection placeholders.
Remove them if not used.
Update the ParserOutput if fetching from ParserCache
2011-10-07 20:50:10 +00:00
Sam Reed
937fc3bcfd Back out r95396 and friends 2011-09-29 22:08:00 +00:00
Alexandre Emsenhuber
0a45e7dc76 Per Aaron, follow-up r93758: add coments and fix typos 2011-09-29 15:14:34 +00:00
Chad Horohoe
c7e950e474 Also add $wgRequest to the forbidden globals...thought it was common sense. 2011-09-27 18:56:44 +00:00
Roan Kattouw
dc4ab75a51 Fix stupid typo in r98193, thanks Dantman 2011-09-26 23:16:32 +00:00
Roan Kattouw
95e857198b (bug 31176) {{SERVERNAME}} doesn't play nice with protocol-relative URLs 2011-09-26 23:14:20 +00:00
Robin Pepermans
07dc087494 Re-do r96798 ("LanguageConverter now depends on the page content language"), without the change in WikiPage which caused an infinite loop (see bug 31098) 2011-09-22 20:31:23 +00:00
Tim Starling
70105f8b85 Reverted r85922 and related: new doTableStuff(). I copied in the old doTableStuff() from before r85922 and reverted all parser test changes that looked vaguely related. Apologies to Platonides, since some of his parser tests appeared to be relevant to the old parser, but it's simplest to just revert all the related changes and then re-add any useful tests later. See CR r85922 for full rationale. 2011-09-15 12:10:53 +00:00
Sam Reed
fb32210aee Whitespace/documentation 2011-09-14 15:07:20 +00:00
Niklas Laxström
c48b41201a Revert r96798 - makes parser go infinite loop somewhere 2011-09-14 11:23:58 +00:00
Aaron Schulz
42ead260a4 Removed parser hacks from r88740, r88741, r88780 2011-09-13 20:26:41 +00:00
Aaron Schulz
23d5a27e2e Reverted r86072, r86419 per CR. Lots of conflicts resolved here. Removes lineStart from r87346 code as well for preprocess parser tests. 2011-09-12 19:16:22 +00:00