Skip to content

Commit

Permalink
Allows '%' and IPv6 in opaque hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Feb 8, 2017
1 parent 85d99da commit 1cacefe
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions url.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ class url_parser {
static bool url_parse(url_serializer& urls, const CharT* first, const CharT* last, const url* base, State state_override = not_set_state);

template <typename CharT>
static bool parse_url_host(url_serializer& urls, const CharT* first, const CharT* last);
static bool parse_opaque_host(url_serializer& urls, const CharT* first, const CharT* last);

template <typename CharT>
static bool parse_host(url_serializer& urls, const CharT* first, const CharT* last);
Expand Down Expand Up @@ -947,7 +947,7 @@ inline bool url_parser::url_parse(url_serializer& urls, const CharT* first, cons
}

// parse and set host:
if (!parse_url_host(urls, pointer, it_host_end))
if (!parse_host(urls, pointer, it_host_end))
return false;

if (is_port) {
Expand Down Expand Up @@ -1268,14 +1268,8 @@ static inline bool is_valid_opaque_host_chars(const CharT* first, const CharT* l
}

template <typename CharT>
inline bool url_parser::parse_url_host(url_serializer& urls, const CharT* first, const CharT* last) {
if (urls.is_special_scheme())
return parse_host(urls, first, last);

// TODO: URL standard bug: percent encoded hosts will be
// reported as invalid by: !is_valid_host_chars(..)

if (!is_valid_host_chars(first, last))
inline bool url_parser::parse_opaque_host(url_serializer& urls, const CharT* first, const CharT* last) {
if (!is_valid_opaque_host_chars(first, last))
return false; //TODO-ERR: failure

std::string& str_host = urls.start_part(url::HOST);
Expand Down Expand Up @@ -1315,6 +1309,9 @@ inline bool url_parser::parse_host(url_serializer& urls, const CharT* first, con
}
}

if (!urls.is_special_scheme())
return parse_opaque_host(urls, first, last);

// check if host has non ascii characters or percent sign
bool has_no_ascii = false;
bool has_escaped = false;
Expand Down

0 comments on commit 1cacefe

Please sign in to comment.