Page MenuHomePhabricator

string.gsub( s, "%%1", repl) fails as "invalid capture index"
Closed, InvalidPublic

Description

When I use:

  • text = string.gsub(text, "%%1", (v1 or "*") )

That fails as "invalid capture index"

Following my each day survey of MW version, the version where the bug appeared is
Mediawiki-Wikisource 1.29.0-wmf.3 (rMWc1e59aaed04f)-UTC-20161123-18:55
which I seen at 20161124-22:36 French time

To continue my work, I repair it using:
local j = string.find(text, "%", 1, true)
local k = string.find(text, "1", 1, true)
if j and k and ( j + 1 == k ) then
form = string.sub(form, 1, j-1) .. tostring(val) .. string.sub(form, k+1)
else
form = string.gsub(form or "gsub", "%%" .. S9, tostring(val) )
end

Event Timeline

Please supply a full test case that illustrates the problem. Ideally something closer to 10 lines than a link to a complex 1000-line module.

I test but not detect an error ?
That come probably from a missing "rep = nil" somewhere in Module:Central.
I tested there.

Sorry for this false alert !