Skip to content

Commit

Permalink
src: make PercentDecode return void
Browse files Browse the repository at this point in the history
It only returns 0, nor is it likely to have any error conditions in the
future.

PR-URL: #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>
  • Loading branch information
TimothyGu authored and MylesBorins committed Mar 28, 2017
1 parent d62ddbe commit 019a20a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/node_url.cc
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ namespace url {
}

// First, we have to percent decode
if (PercentDecode(input, length, &decoded) < 0)
goto end;
PercentDecode(input, length, &decoded);

// If there are any invalid UTF8 byte sequences, we have to fail.
// Unfortunately this means iterating through the string and checking
Expand Down
11 changes: 5 additions & 6 deletions src/node_url.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@ static inline unsigned hex2bin(const char ch) {
return static_cast<unsigned>(-1);
}

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

#define SPECIALS(XX) \
Expand Down

0 comments on commit 019a20a

Please sign in to comment.