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: nodejs#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]>
  • Loading branch information
TimothyGu committed Mar 22, 2017
1 parent c515a98 commit d231236
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 @@ -368,8 +368,7 @@ namespace url {
}

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

// Then we have to punycode toASCII
if (!ToASCII(&decoded, &decoded))
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 d231236

Please sign in to comment.