From e17d14a38e2d78926c0a0fb5de6a1e451fd76524 Mon Sep 17 00:00:00 2001 From: Ivan Vilata-i-Balaguer Date: Tue, 19 Jun 2018 10:48:02 -0400 Subject: [PATCH] Fix parsing of URLs containing IPv6 addresses That includes the front-end accepting things like ``[::1]`` and the injector accepting URLs like ``http://[2001:db8::1]:8080/foo/bar``. --- src/client_front_end.cpp | 2 +- src/injector.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client_front_end.cpp b/src/client_front_end.cpp index 3f9be7de..5f3d20d1 100644 --- a/src/client_front_end.cpp +++ b/src/client_front_end.cpp @@ -64,7 +64,7 @@ static ostream& operator<<(ostream& os, const ClientFrontEnd::Task& task) { static string path_from_url(const string& url) { // This is not a bullet-proof URL parser, it just gets some common cases here. - static const boost::regex urlrx("^(?:http://[-\\.a-z0-9]+)?(/[^?#]*).*"); + static const boost::regex urlrx("^(?:http://[-\\.:\\[\\]a-z0-9]+)?(/[^?#]*).*"); boost::smatch url_match; boost::regex_match(url, url_match, urlrx); return url_match[1]; diff --git a/src/injector.cpp b/src/injector.cpp index 86b0d541..9cd89676 100644 --- a/src/injector.cpp +++ b/src/injector.cpp @@ -132,7 +132,7 @@ struct InjectorCacheControl { // Parse the URL to tell HTTP/HTTPS, host, port. auto target = rq.target().to_string(); - static const boost::regex urlrx("^(http|https)://([-\\.a-z0-9]+)(:[0-9]{1,5})?/.*"); + static const boost::regex urlrx("^(http|https)://([-\\.a-z0-9]+|\\[[:0-9a-fA-F]+\\])(:[0-9]{1,5})?/.*"); boost::smatch url_match; if (!boost::regex_match(target, url_match, urlrx)) { ec = asio::error::operation_not_supported; // unsupported URL