mirror of
https://github.com/gnosygnu/xowa.git
synced 2024-10-27 20:34:16 +00:00
Scribunto: Do not return early in Gsub if source is String.empty [#731]
This commit is contained in:
parent
ad607d952c
commit
062d308128
@ -49,6 +49,12 @@ public class Scrib_lib_ustring__gsub__tst {
|
||||
// TOMBSTONE: tested with local MW and {{#invoke:Test|test16|a|[^]|b}} -> Lua error: Missing close-bracket for character set beginning at pattern character 1.; DATE:2018-07-02
|
||||
// Exec_gsub("a" , "[^]" , 1, "b" , "a;0"); // invalid regx should not fail; should return self; DATE:2013-10-20
|
||||
}
|
||||
@Test public void ReplaceEmptyWithPattern() {
|
||||
Exec_gsub("", "a", -1, "A", ";0");
|
||||
}
|
||||
@Test public void ReplaceEmptyWithFlag() {
|
||||
Exec_gsub("", "$", -1, "A", "A;1");
|
||||
}
|
||||
@Test public void Find__int() {// PURPOSE: gsub with integer arg should not fail; DATE:2013-11-06
|
||||
fxt.Test__proc__kvps__flat(lib, Scrib_lib_ustring.Invk_gsub, Scrib_kv_utl_.base1_many_(1, "[1]", "2", 1), "2;1"); // NOTE: text is integer (lua / php are type-less)
|
||||
}
|
||||
|
@ -52,9 +52,8 @@ class Scrib_pattern_matcher__xowa extends Scrib_pattern_matcher {
|
||||
// get src vars
|
||||
String src_str = src_ucs.Src();
|
||||
int src_len = src_ucs.Len_in_data();
|
||||
if (src_len == 0) {
|
||||
return src_str;
|
||||
}
|
||||
// TOMBSTONE:do not return early if String.empty; allows `string.gsub('', '$', 'a')` ISSUE#:731; DATE:2020-07-20
|
||||
// if (src_len == 0) return src_str;
|
||||
int src_max = src_len + 1;
|
||||
|
||||
// get pat vars
|
||||
|
Loading…
Reference in New Issue
Block a user