Welcome! Log In Create A New Profile

Advanced

[njs] Fixed encoding matching for base64url in String.bytesFrom().

Alexander Borisov
December 22, 2020 10:38AM
details: https://hg.nginx.org/njs/rev/92c0493b2aff
branches:
changeset: 1584:92c0493b2aff
user: Disconnect3d <dominik.b.czarnota@gmail.com>
date: Tue Dec 22 13:27:01 2020 +0100
description:
Fixed encoding matching for base64url in String.bytesFrom().

This closes #363 PR on GitHub.

diffstat:

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

diffs (25 lines):

diff -r d8e94445f59b -r 92c0493b2aff src/njs_string.c
--- a/src/njs_string.c Wed Dec 16 20:27:43 2020 +0000
+++ b/src/njs_string.c Tue Dec 22 13:27:01 2020 +0100
@@ -1753,7 +1753,7 @@ njs_string_bytes_from_string(njs_vm_t *v
} else if (enc.length == 6 && memcmp(enc.start, "base64", 6) == 0) {
return njs_string_decode_base64(vm, &vm->retval, &str);

- } else if (enc.length == 9 && memcmp(enc.start, "base64url", 6) == 0) {
+ } else if (enc.length == 9 && memcmp(enc.start, "base64url", 9) == 0) {
return njs_string_decode_base64url(vm, &vm->retval, &str);
}

diff -r d8e94445f59b -r 92c0493b2aff src/test/njs_unit_test.c
--- a/src/test/njs_unit_test.c Wed Dec 16 20:27:43 2020 +0000
+++ b/src/test/njs_unit_test.c Tue Dec 22 13:27:01 2020 +0100
@@ -9016,6 +9016,9 @@ static njs_unit_test_t njs_test[] =
{ njs_str("String.bytesFrom('QUJDRA#', 'base64url')"),
njs_str("ABCD") },

+ { njs_str("String.bytesFrom('QUJDRA#', 'base64lol')"),
+ njs_str("TypeError: Unknown encoding: \"base64lol\"") },
+
{ njs_str("encodeURI.name"),
njs_str("encodeURI")},

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

[njs] Fixed encoding matching for base64url in String.bytesFrom().

Alexander Borisov 80 December 22, 2020 10:38AM



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

Online Users

Guests: 51
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready