Welcome! Log In Create A New Profile

Advanced

[njs] Fixed parsing of "$&" substitutions in String.prototype.replace().

Alexander Borisov
July 16, 2019 10:34AM
details: https://hg.nginx.org/njs/rev/738f2410b532
branches:
changeset: 1054:738f2410b532
user: Alexander Borisov <alexander.borisov@nginx.com>
date: Tue Jul 16 17:32:11 2019 +0300
description:
Fixed parsing of "$&" substitutions in String.prototype.replace().

diffstat:

njs/njs_string.c | 3 ---
njs/test/njs_unit_test.c | 3 +++
2 files changed, 3 insertions(+), 3 deletions(-)

diffs (26 lines):

diff -r 8ac396f1a20c -r 738f2410b532 njs/njs_string.c
--- a/njs/njs_string.c Tue Jul 16 17:32:11 2019 +0300
+++ b/njs/njs_string.c Tue Jul 16 17:32:11 2019 +0300
@@ -3513,9 +3513,6 @@ skip:

type *= 2;

- } else if (c == '&') {
- type = 0;
-
} else if (c == '`') {
type = NJS_SUBST_PRECEDING;

diff -r 8ac396f1a20c -r 738f2410b532 njs/test/njs_unit_test.c
--- a/njs/test/njs_unit_test.c Tue Jul 16 17:32:11 2019 +0300
+++ b/njs/test/njs_unit_test.c Tue Jul 16 17:32:11 2019 +0300
@@ -5684,6 +5684,9 @@ static njs_unit_test_t njs_test[] =
{ nxt_string("typeof String.bytesFrom(Array(15).fill(0xE3)).replace(/^/g, 1)"),
nxt_string("string") },

+ { nxt_string("typeof '0'.replace(/^/g, '$&')"),
+ nxt_string("string") },
+
{ nxt_string("/]/"),
nxt_string("/\\]/") },

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Fixed parsing of "$&" substitutions in String.prototype.replace().

Alexander Borisov 172 July 16, 2019 10:34AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 292
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready