Skip to content

Commit 019a20a

Browse files
TimothyGuMylesBorins
authored andcommitted
src: make PercentDecode return void
It only returns 0, nor is it likely to have any error conditions in the future. PR-URL: #11922 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent d62ddbe commit 019a20a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/node_url.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,7 @@ namespace url {
375375
}
376376

377377
// First, we have to percent decode
378-
if (PercentDecode(input, length, &decoded) < 0)
379-
goto end;
378+
PercentDecode(input, length, &decoded);
380379

381380
// If there are any invalid UTF8 byte sequences, we have to fail.
382381
// Unfortunately this means iterating through the string and checking

src/node_url.h

+5-6
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,11 @@ static inline unsigned hex2bin(const char ch) {
376376
return static_cast<unsigned>(-1);
377377
}
378378

379-
static inline int PercentDecode(const char* input,
380-
size_t len,
381-
std::string* dest) {
379+
static inline void PercentDecode(const char* input,
380+
size_t len,
381+
std::string* dest) {
382382
if (len == 0)
383-
return 0;
383+
return;
384384
dest->reserve(len);
385385
const char* pointer = input;
386386
const char* end = input + len;
@@ -399,11 +399,10 @@ static inline int PercentDecode(const char* input,
399399
unsigned a = hex2bin(pointer[1]);
400400
unsigned b = hex2bin(pointer[2]);
401401
char c = static_cast<char>(a * 16 + b);
402-
*dest += static_cast<char>(c);
402+
*dest += c;
403403
pointer += 3;
404404
}
405405
}
406-
return 0;
407406
}
408407

409408
#define SPECIALS(XX) \

0 commit comments

Comments
 (0)