If the parser function returns 'isChildObj', we need to create a child
frame to expand the wikitext returned by the parser function. And when
we pass the arguments to the new frame, we need to pass them through the
preprocessor's newPartNodeArray() first.
Bug: 50863
Change-Id: Ieb7cc7007288de1f7d2cd2458f068affe695e8af
Users seem to expect that mw.language's parseFormattedNumber will act
like tonumber when given nil or other non-string values, returning nil
instead of raising an error. There's no reason not to, so we may as
well.
Change-Id: Ie0ff19efc84ca738e115bbd524bfd92fccf26127
A few edge cases were being incorrectly handled:
* mw.ustring.sub( 'abc', 1, 0 ) returned 'a', not ''.
* mw.ustring.codepoint( 'abc', 1, 0 ) returned 97, not no results.
* mw.ustring.codepoint( 'abc', 4, 4 ) returned 99, not no results.
* mw.ustring.gcodepoint had the same issues as mw.ustring.codepoint.
Change-Id: Ib8c0ef5a8073106eb7d90d0aa0513be4525dca08
Negative values for 'i' in mw.ustring.byteoffset are supposed to count
from the end of the string. But in LuaSandbox, it was actually counting
from two bytes before the end of the string due to a typo.
Fix that, and add some tests for it.
Bug: 50176
Change-Id: Iceee1022a55abd7a08df1ea7843e1277eb02798b
If someone puts something broken in MediaWiki:Scribunto-doc-page-name,
it may not be possible to determine which module the page is a doc page
for. In that case, just pretend it's not a doc page.
Bug: 49322
Change-Id: Ia4421576b372e188cf7e3dfe2c0b8ce213d026d4
If the interpreter exits before the end of the page, then the call to
Scribunto_LuaStandaloneEngine::getLimitReport() throws an uncaught
exception when it tries to access the interpreter. Catch it.
Change-Id: I7ce4f09b1b2206f13ab0f422de35e0b69a3b24d5
The "%f[set]" frontier pattern has been in Lua 5.1 since the beginning,
but was undocumented until Lua 5.2. And the code is even unchanged from
5.1.0 to 5.2.1. So there's no reason not to implement it in ustring too.
Note the changes to UstringLibrary.php are somewhat large, because it
splits the "convert a Lua bracketed charset to PCRE" code into a
separate function and it changes the handling of mw.ustring.find's and
mw.ustring.match's 'init' parameter from "substring, match from 0, then
add back on $init" to "use preg_match's $offset and use \G instead of ^
where this matters". Both of these are necessary to properly support
%f.
This also fixes a bug in the pure-Lua code (not used in Scribunto)
exposed by the unit tests for %f where %z was matching '\1' rather than
'\0' and %Z everything except '\1' instead of everything except '\0'.
Bug: 48331
Change-Id: Ie0b95ef5b734db53d6adc9de5dae4874f8944c08
The following errors are fixed:
* PHP warning and wrong return value with empty pattern and plain
* Incorrect offsets returned when init is larger than the string length
* Incorrect captured offsets returned when init is excessively negative
Bug: 47365
Change-Id: I9741418287dc727747326d6a19678370ce155a2b
We had intended to use the constant CONTENT_FORMAT_TEXT, but
accidentally used that as a string instead.
Change-Id: I93a2c02d48d3fd7b73530562165d817965e272d1
* zh names are dropped to use fallback.
* zh-yue is renamed to yue, with talk namespace name added.
Change-Id: I9b0e0e5ab03a70bcbbc052ef4e6c753574e73e13
Two related issues:
* The package module was inheriting the loaders from the outer sandbox,
so loaded modules were being loaded into the outer sandbox's
environment.
* mw.loadData was using the outer sandbox's require(), so again loaded
modules were being loaded into the outer sandbox's environment.
Bug: 47300
Change-Id: I48d8dd4784c9a890e3abb6389f96f38e1420dbbb
The documentation, and the expectation of users, is that
lang:parseFormattedNumber() should actually return a number, not a
string.
Bug: 47268
Change-Id: Ieabddd0d9192f1fd8ef7e890d5d6268be9636f38
One of the design goals of Scribunto is that each #invoke should be
independent. Creative use of mw.log and mw.getLogBuffer can get around
this, passing information from one #invoke to the next.
This patch takes the simple solution of removing mw.getLogBuffer from
modules' environments. For good measure, it also removes
mw.clearLogBuffer and mw.executeModule.
Some minor cleanup of the console code is also included.
Change-Id: I30d73928bade4a6bdd7c00ffcd58a3858ff55698