# # # patch "Makefile.am" # from [a0ed2ec6eda766d2da11b80abf961781e4c486b9] # to [aa16cec062acc61ff08a508bd5c0b987738cf8fa] # # patch "uri.cc" # from [33af93af2c742dd75d257121d1a62b105adc2582] # to [cde1447e4a6c84a7d6397471930847524754283a] # ============================================================ --- Makefile.am a0ed2ec6eda766d2da11b80abf961781e4c486b9 +++ Makefile.am aa16cec062acc61ff08a508bd5c0b987738cf8fa @@ -192,7 +192,7 @@ UNIT_TEST_SUPPORT = \ UNIT_TEST_SUPPORT = \ constants.cc file_io.cc gzip.cc hmac.cc lcs.cc merkle_tree.cc \ randomizer.cc randomizer.hh roster_delta.cc roster_tests.hh \ - sanity.cc specialized_lexical_cast.cc + sanity.cc specialized_lexical_cast.cc pcrewrap.cc # primaries ============================================================ --- uri.cc 33af93af2c742dd75d257121d1a62b105adc2582 +++ uri.cc cde1447e4a6c84a7d6397471930847524754283a @@ -8,6 +8,7 @@ // PURPOSE. #include "base.hh" +#include "pcrewrap.hh" #include "sanity.hh" #include "uri.hh" @@ -70,11 +71,42 @@ parse_authority(string const & in, uri_t } } +static bool +try_parse_bare_authority(string const & in, uri_t & uri, origin::type made_from) +{ + if (in.empty()) + return false; + + pcre::regex hostlike("^(" + "[^:/]+(:[0-9]+)?" // hostname or ipv4 + "|" + "[:0-9a-fA-F]+" // non-bracketed ipv6 + "|" + "\[[:0-9a-fA-F]+\](:[0-9]+)?" // bracketed ipv6 + ")$", + origin::internal); + + if (hostlike.match(in, made_from)) + { + parse_authority(in, uri, made_from); + return true; + } + else + { + return false; + } +} + void parse_uri(string const & in, uri_t & uri, origin::type made_from) { uri.clear(); + if (try_parse_bare_authority(in, uri, made_from)) + { + return; + } + stringpos p = 0; // This is a simplified URI grammar. It does the basics.