This also makes some updates to make-normalization-table.php to handle
the move of UtfNormal to a separate library.
Bug: T126427
Change-Id: Id4985c3ca441cf92f08ba1f1af85c762ba43d7d2
When caching results from frame:preprocess and frame:expandTemplate,
restrict the scope of the cache to the frame object that was used. This
allows the integrity of the empty-frame expansion cache to be maintained
while also allowing parent frame access. This change is the equivalent of
I621e9075 in core.
Change-Id: Iae4c00e7e19ba12cfdaac135be16c991d9d0cea1
Apparently microtime is a bit unreliable for this test for some reason,
so let's use getrusage() to measure actual CPU time instead.
Bug: T125045
Change-Id: Ia1ab6b043b99abb4fc6c2989ad09a24d97dd09c3
HHVM has a bug in json decode https://github.com/facebook/hhvm/issues/5813 .
Skip the test until there is a fix upstream.
Bug: T103346
Change-Id: I7e44d98c29ba9b9f5443665fc046382f696193c9
Lua actually treats a close-bracket at the start of a bracketed
character class as a literal, rather than using it to close the
character class. Probably unintended behavior, but it happens.
Also, have the pure-lua version throw our more informative errors on
error even when falling back to string.find and the like, and fix some
other weird edge cases that came up in testing.
Bug: T95958
Bug: T115686
Change-Id: Iab783d4a3e58b1514cc09729d4a71c2cb1242ee8
A string with a dot pattern is only "simple" if
followed by +, - or *. The end of string condition was not checked
properly.
Change-Id: Ia10b9164caeabe464c76441cc82eef37a7013048
And now Ie9e334e broke the tests again. Why can't anyone be bothered to
fix things they should *know* by now are going to need fixing?
Bug: T90018
Change-Id: I7f71dda4af38b23f89c64b6116c1145c44f5c523
The parser's output was changed in I562e437e to add clickable anchors
for section headers which made Scribunto parser tests fail.
Bug: T90018
Change-Id: Ia74877e0641f2763d42be4a8fad1aa8ecffe449e
Should be good to apply now after Wikibase has been adopted to
this.
This reverts commit 06f03fe09b.
Bug: T69483
Change-Id: I28073a891b8847fc6aa5ad026bf702e4015f7d4a
* For most tests, subclassing MediaWikiLangTestCase instead of
MediaWikiTestCase works.
* The Site library needs to not reuse its namespace cache if the
language changed.
* ScribuntoExceptions are still being localized for some reason; test
the message and args of the exception instead of using getMessage().
Bug: T69483
Change-Id: I1c0ca3b11b6228654b47ceb92c1b1be7bda6709a
* I0ede3169 caused Language::fetchLanguageNames() to use 'en' rather than
null when given an invalid language code. This didn't break Jenkins
since, without cldr, it always uses null anyway.
* I4bead5f5 caused Language::listToText() to start encoding
single-quotes in messages such as 'and'.
Bug: T85854
Change-Id: Ic2807be8dad3ef029652e4b0db05e4dd8a6631b9
This makes the interwiki map available to Lua modules. The code is
based on the API interwiki map code in core (the appendInterwikiMap
method of includes/api/ApiQuerySiteInfo.php.) Everything that the
API includes is added, apart from iw_api and iw_wikiid, which I
couldn't think of a use for from Lua modules.
Accessing the interwiki map would be useful for modules like
enwiki's Module:InterwikiTable,[1] as it would stop module writers
having to duplicate the data.
[1] https://en.wikipedia.org/wiki/Module:InterwikiTable
Change-Id: Ie8ad2582aaf5e422824f7da51714a347bb4041d1
When os.date("*t") or ("!*t") is called, instead of just setting the TTL
to 1 second, create a metatable that sets TTLs as the values are looked
at.
Change-Id: Id1e2df731f182f21cf19708738f9907fa927185c
Currently, mw.title.new always results in a database query, which holds up
the parse until it finishes. This changes it to not require a database
query if it's not actually necessary.
Bug: T68328
Change-Id: I62f347d4cd9176bd0440215dcbe804c1dc3d4c99
Add more information to error messages in mw.html. This includes the
error level, the function name, and the position of the argument in the
argument list. Where possible, use the functions in libraryUtil.lua to
do this.
Some functions in mw.html accept multiple types, so add a checkTypeMulti
function to libraryUtil.lua to make these kinds of functions easy to check.
And while we're at it, add test cases for libraryUtil.lua as well.
Change-Id: If9cf9a52bd4b1bb42cc7f9f1f1096828710cbc52
mw.text.unstrip is too broad, it's allowing for unstripping things that
cause problems when unstripped (e.g. bug 61268). Since the original
request was only for unstripping <nowiki>, let's add a function that
does only that.
We should also add an interface to StripState::killMarkers(), instead of
requiring everyone to roll their own work-alike.
Then, to fix the bug, we can make mw.text.unstrip be the combination of
the two. This is the most like the original behavior of mw.text.unstrip
(removes all strip markers, replacing them with text where applicable)
without causing issues.
Bug: 61268
Change-Id: I3a151fd678b365d629b71b4f1cb0d5d284b98555
Scribunto currently supports libraries with PHP callbacks that are
loaded on startup, and pure-Lua libraries that may be loaded from the
module with require().
This change allows for libraries with PHP callbacks to also be loaded
with require().
Change-Id: Ibdc1f4ef51b1c8644c3d4c98d57755b5c06447a5
Instead of just displaying "Script error" in wikitext, display the actual
error string. Currently, many users don't see meaningful error messages
generated by modules, and instead just assume that "Script error" means
the module itself has a bug.
Bug: 71038
Change-Id: Ie5358049975352e0fef92088a06b97ad94717000
It's not necessary, it makes the output bigger, and some pages have enough
elements with CSS that it does make an actual difference.
Change-Id: I80d471899c7e04a8a4876c205198a8c0d0b1f281
If a function name contains an equals sign, it doesn't increase the index,
so indexOffset=1 makes Lua see arguments as starting with 0. This change
fixes that, so that indexOffset is only set to 1 if the function name has
an index.
Change-Id: Ifa2dfad4d2f7228c3fd5721ccfc4c235576b663d
Add a way to fetch cascading protection information from Lua without
needing to call the CASCADINGSOURCES parser function.
Change-Id: I1b3ac18af11d3066f78d27b31da8d6709a6a2631
The pure-Lua ustring pattern matching functions short-circuit to the
much faster string library when the pattern would match the same against
the raw bytes.
A pattern like "[^a-z]" can match a partial UTF-8 character when applied
bytewise, and so must be detected as unsafe.
Let's also directly test the pure-Lua module, instead of me having to
comment out lines in Scribunto_LuaUstringLibrary::register() whenever I
want to test them.
Change-Id: I91ed3374aadfea379b9db2e13b4248ab20df509e
Clean up trailing whitespace from all of our code, and add comments
indicating that apparently unused variables are ScopedCallbacks.
Change-Id: I8e5997797cc7b1c64c5351ec112a18f30edc8fef
Two similar bugs are handled here:
* mw.getCurrentFrame() doesn't work when the module is loaded (only when
a function is called), which breaks os.date and os.time at module
scope since I59ad364d.
* mw.getCurrentFrame() gives access to frame args from inside
mw.loadData, which allows for data leakage between #invokes.
Bug: 67498
Bug: 65687
Change-Id: I82dde43e2601b59c03c6ed4b9365829c40a953a5
From the PHP subclass of Scribunto_LuaEngineTestBase, Lua tests run by
Scribunto_LuaEngineTestBase::testLua() may be skipped by adding an entry
for the test name to $this->skipTests.
From the Lua code run by Scribunto_LuaEngineTestBase::testLua(), tests
may be skipped by calling the "markTestSkipped" function exported by the
TestFramework module.
Also, use this new mechanism to skip certain mw.language tests if
Extension:CLDR or a similar extension is not available.
Bug: 67343
Change-Id: I4f0b15073a84bf2f9d8a5d905c3c960941dd2b71
Some functions in mw.html accept numbers as arguments, but later fail when
constructing the string. This disallows numbers in attribute names, since
they aren't valid anyway, and fixes the remainder of the cases to properly
build the string.
Bug: 67201
Change-Id: Ie7bcbb9d8df580dd8793681f78a8b0719d8a287a
Lua's string functions tend to auto-convert numbers to strings. We
should do the same in mw.ustring.
Bug: 67201
Change-Id: Icd3c5e93bac19dafd78d737ec9b315daba9f1729
Certain wikitext, such as that containing Cite.php <ref> or <references>
or the #tag versions of the same, should not be cached. This uses the
isVolatile method added to PPFrame in I95b3cf87 to avoid caching the
preprocessed output of such wikitext from frame:preprocess and similar
methods.
Bug: 46815
Change-Id: I1084f87fd863eb22f2f3f3d3ff308b24e20a08ef
When os.date, os.time, or mw.language:formatDate are called, set the
appropriate TTL on the output. This needs I412febf3 in core to function at
all, and I3f5a80aa in core to function with formatDate.
Change-Id: I59ad364d502fc247500d94c5606516ad9f98a24d
Rather than calling error() when nils get passed to mw.html methods,
either remove whatever it was that the nil would go to (if that makes
sense), or just do nothing. The seemingly inconsistent use of "not x" and
"x ~= nil" is to allow any falsey value where it wouldn't be ambiguous
(such as class names), but not where it could be (such as attribute values).
Bug: 62982
Change-Id: I76773abbb4394aa9bb8c8a08445e019cade3b2bf