url: fix remaining calculation

Fix remaining calculation in the PercentDecode function to match the
definition in URL standard: https://url.spec.whatwg.org/#remaining

PR-URL: https://github.com/nodejs/node/pull/15637
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
This commit is contained in:
Rimas Misevičius 2017-09-27 11:51:35 +03:00 committed by James M Snell
parent e0edb00762
commit 09b703bd3c

View File

@ -518,7 +518,7 @@ static inline void PercentDecode(const char* input,
while (pointer < end) {
const char ch = pointer[0];
size_t remaining = (end - pointer) + 1;
const size_t remaining = end - pointer - 1;
if (ch != '%' || remaining < 2 ||
(ch == '%' &&
(!IsASCIIHexDigit(pointer[1]) ||