mirror of
https://github.com/ccxvii/mujs.git
synced 2026-02-05 17:29:43 +08:00
Issue #202: Special case for empty substring that splits surrogate pair.
The code to split non-BMP characters into surrogate pairs assumes that we are actually splitting a character, and will fail when we ask it to create a zero-length string in the middle of a surrogate pair split. Special case zero-length substrings to work around this.
This commit is contained in:
@@ -288,8 +288,10 @@ static void Sp_slice(js_State *J)
|
||||
|
||||
if (s < e)
|
||||
Sp_substring_imp(J, str, s, e - s);
|
||||
else
|
||||
else if (s > e)
|
||||
Sp_substring_imp(J, str, e, s - e);
|
||||
else
|
||||
js_pushliteral(J, "");
|
||||
}
|
||||
|
||||
static void Sp_substring(js_State *J)
|
||||
@@ -304,8 +306,10 @@ static void Sp_substring(js_State *J)
|
||||
|
||||
if (s < e)
|
||||
Sp_substring_imp(J, str, s, e - s);
|
||||
else
|
||||
else if (s > e)
|
||||
Sp_substring_imp(J, str, e, s - e);
|
||||
else
|
||||
js_pushliteral(J, "");
|
||||
}
|
||||
|
||||
static void Sp_toLowerCase(js_State *J)
|
||||
|
||||
Reference in New Issue
Block a user