[njs] Updated the list of space separators in String.prototype.trim().
Valentin Bartenev
vbart at nginx.com
Sun Jul 28 10:16:22 UTC 2019
details: https://hg.nginx.org/njs/rev/ac39f4c902b5
branches:
changeset: 1078:ac39f4c902b5
user: Valentin Bartenev <vbart at nginx.com>
date: Sun Jul 28 13:17:13 2019 +0300
description:
Updated the list of space separators in String.prototype.trim().
According to the specification it must include all Unicode code points listed
in the "Space_Separator" (Zs) category.
diffstat:
njs/njs_string.c | 30 ++++++++++++++++++++++++++++++
njs/test/njs_unit_test.c | 10 ++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diffs (71 lines):
diff -r 575c018f2206 -r ac39f4c902b5 njs/njs_string.c
--- a/njs/njs_string.c Sat Jul 27 21:12:32 2019 +0300
+++ b/njs/njs_string.c Sun Jul 28 13:17:13 2019 +0300
@@ -2425,8 +2425,23 @@ njs_string_prototype_trim(njs_vm_t *vm,
case 0x000D: /* <CR> */
case 0x0020: /* <SP> */
case 0x00A0: /* <NBSP> */
+ case 0x1680:
+ case 0x2000:
+ case 0x2001:
+ case 0x2002:
+ case 0x2003:
+ case 0x2004:
+ case 0x2005:
+ case 0x2006:
+ case 0x2007:
+ case 0x2008:
+ case 0x2009:
+ case 0x200A:
case 0x2028: /* <LS> */
case 0x2029: /* <PS> */
+ case 0x202F:
+ case 0x205F:
+ case 0x3000:
case 0xFEFF: /* <BOM> */
trim++;
continue;
@@ -2448,8 +2463,23 @@ njs_string_prototype_trim(njs_vm_t *vm,
case 0x000D: /* <CR> */
case 0x0020: /* <SP> */
case 0x00A0: /* <NBSP> */
+ case 0x1680:
+ case 0x2000:
+ case 0x2001:
+ case 0x2002:
+ case 0x2003:
+ case 0x2004:
+ case 0x2005:
+ case 0x2006:
+ case 0x2007:
+ case 0x2008:
+ case 0x2009:
+ case 0x200A:
case 0x2028: /* <LS> */
case 0x2029: /* <PS> */
+ case 0x202F:
+ case 0x205F:
+ case 0x3000:
case 0xFEFF: /* <BOM> */
trim++;
continue;
diff -r 575c018f2206 -r ac39f4c902b5 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Sat Jul 27 21:12:32 2019 +0300
+++ b/njs/test/njs_unit_test.c Sun Jul 28 13:17:13 2019 +0300
@@ -5653,6 +5653,16 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("'\\u2029abc\\uFEFF\\u2028'.trim()"),
nxt_string("abc") },
+#if (!NXT_HAVE_MEMORY_SANITIZER) /* very long test under MSAN */
+ { nxt_string("var a = [], code;"
+ "for (code = 0; code <= 1114111; code++) {"
+ " var ws = String.fromCodePoint(code);"
+ " if ((ws + '-' + ws).trim() === '-')"
+ " a.push(code);"
+ "} a"),
+ nxt_string("9,10,11,12,13,32,160,5760,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8232,8233,8239,8287,12288,65279") },
+#endif
+
{ nxt_string("'abcdefgh'.search()"),
nxt_string("0") },
More information about the nginx-devel
mailing list