0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

src: make PercentDecode return void

It only returns 0, nor is it likely to have any error conditions in the
future.

PR-URL: https://github.com/nodejs/node/pull/11922
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Timothy Gu 2017-03-16 16:46:12 -07:00
parent c515a985ea
commit d23123643d
2 changed files with 6 additions and 8 deletions

View File

@ -368,8 +368,7 @@ namespace url {
} }
// First, we have to percent decode // First, we have to percent decode
if (PercentDecode(input, length, &decoded) < 0) PercentDecode(input, length, &decoded);
goto end;
// Then we have to punycode toASCII // Then we have to punycode toASCII
if (!ToASCII(&decoded, &decoded)) if (!ToASCII(&decoded, &decoded))

View File

@ -376,11 +376,11 @@ static inline unsigned hex2bin(const char ch) {
return static_cast<unsigned>(-1); return static_cast<unsigned>(-1);
} }
static inline int PercentDecode(const char* input, static inline void PercentDecode(const char* input,
size_t len, size_t len,
std::string* dest) { std::string* dest) {
if (len == 0) if (len == 0)
return 0; return;
dest->reserve(len); dest->reserve(len);
const char* pointer = input; const char* pointer = input;
const char* end = input + len; const char* end = input + len;
@ -399,11 +399,10 @@ static inline int PercentDecode(const char* input,
unsigned a = hex2bin(pointer[1]); unsigned a = hex2bin(pointer[1]);
unsigned b = hex2bin(pointer[2]); unsigned b = hex2bin(pointer[2]);
char c = static_cast<char>(a * 16 + b); char c = static_cast<char>(a * 16 + b);
*dest += static_cast<char>(c); *dest += c;
pointer += 3; pointer += 3;
} }
} }
return 0;
} }
#define SPECIALS(XX) \ #define SPECIALS(XX) \