# # # patch "cmd_netsync.cc" # from [8bfd914c3727818036e83c65f72cff22cca86222] # to [e3e652b9d07969440f9126abbbb0f5f14c28d2ed] # # patch "lua_hooks.cc" # from [14c47b49b38e31bc04dd47c1ea5d53231c772f8d] # to [77302e7ceffc015282217e6557093432761c606e] # # patch "lua_hooks.hh" # from [13b02250e084d7e1d04d9df095f4409d3b6189bb] # to [66dc21dc1fad41f217c026729dda415d8051fdff] # # patch "netcmd.hh" # from [9fd97280633714008862a4a261403461d335fed5] # to [0dcc01c8e199edfc548f12a76a4adcf7b824a8bf] # # patch "netsync.cc" # from [8aa8a063c4a6a506a7e30d2e1ff85a38da445253] # to [5fa0c7f976f5570e48a91edea6d085e15e6d7acf] # # patch "unit-tests/uri.cc" # from [be871d7b14f2fd2c066b4759ae43abc2f2d08912] # to [6a59bc8b989d98385aee5ca69195d02bcfae7d7d] # # patch "uri.cc" # from [1c57c3a5fa0f0899e60e71b2b79caea4d1c3596d] # to [33af93af2c742dd75d257121d1a62b105adc2582] # # patch "uri.hh" # from [4ee1882809ef881390a703fb31e2a41a3258c70c] # to [9afc3c0849902ced57c34161c7a0e63ce6ca09da] # ============================================================ --- cmd_netsync.cc 8bfd914c3727818036e83c65f72cff22cca86222 +++ cmd_netsync.cc e3e652b9d07969440f9126abbbb0f5f14c28d2ed @@ -57,8 +57,8 @@ find_key(options & opts, bool need_key = true) { utf8 host(info.client.unparsed); - if (!info.client.u.host.empty()) - host = utf8(info.client.u.host, origin::user); + if (!info.client.uri.host.empty()) + host = utf8(info.client.uri.host, origin::user); cache_netsync_key(opts, lua, db, keys, host, info.client.include_pattern, @@ -86,8 +86,8 @@ build_client_connection_info(options & o info.client.unparsed = typecast_vocab(addr_value); L(FL("using default server address: %s") % info.client.unparsed); } - parse_uri(info.client.unparsed(), info.client.u, origin::user); - if (info.client.u.query.empty() && !include_or_exclude_given) + parse_uri(info.client.unparsed(), info.client.uri, origin::user); + if (info.client.uri.query.empty() && !include_or_exclude_given) { // No include/exclude given anywhere, use the defaults. E(db.var_exists(default_include_pattern_key), origin::user, @@ -106,7 +106,7 @@ build_client_connection_info(options & o info.client.exclude_pattern = globish(); L(FL("excluding: %s") % info.client.exclude_pattern); } - else if(!info.client.u.query.empty()) + else if(!info.client.uri.query.empty()) { E(!include_or_exclude_given, origin::user, F("Include/exclude pattern was given both as part of the URL and as a separate argument.")); @@ -114,7 +114,7 @@ build_client_connection_info(options & o // Pull include/exclude from the query string char const separator = '/'; char const negate = '-'; - string const & query(info.client.u.query); + string const & query(info.client.uri.query); std::vector includes, excludes; string::size_type begin = 0; string::size_type end = query.find(separator); @@ -182,12 +182,12 @@ build_client_connection_info(options & o } info.client.use_argv = - lua.hook_get_netsync_connect_command(info.client.u, + lua.hook_get_netsync_connect_command(info.client.uri, info.client.include_pattern, info.client.exclude_pattern, global_sanity.debug_p(), info.client.argv); - opts.use_transport_auth = lua.hook_use_transport_auth(info.client.u); + opts.use_transport_auth = lua.hook_use_transport_auth(info.client.uri); if (opts.use_transport_auth) { find_key(opts, lua, db, keys, info, need_key); ============================================================ --- lua_hooks.cc 14c47b49b38e31bc04dd47c1ea5d53231c772f8d +++ lua_hooks.cc 77302e7ceffc015282217e6557093432761c606e @@ -615,62 +615,62 @@ static void } static void -push_uri(uri const & u, Lua & ll) +push_uri(uri_t const & uri, Lua & ll) { ll.push_table(); - if (!u.scheme.empty()) + if (!uri.scheme.empty()) { ll.push_str("scheme"); - ll.push_str(u.scheme); + ll.push_str(uri.scheme); ll.set_table(); } - if (!u.user.empty()) + if (!uri.user.empty()) { ll.push_str("user"); - ll.push_str(u.user); + ll.push_str(uri.user); ll.set_table(); } - if (!u.host.empty()) + if (!uri.host.empty()) { ll.push_str("host"); - ll.push_str(u.host); + ll.push_str(uri.host); ll.set_table(); } - if (!u.port.empty()) + if (!uri.port.empty()) { ll.push_str("port"); - ll.push_str(u.port); + ll.push_str(uri.port); ll.set_table(); } - if (!u.path.empty()) + if (!uri.path.empty()) { ll.push_str("path"); - ll.push_str(u.path); + ll.push_str(uri.path); ll.set_table(); } - if (!u.query.empty()) + if (!uri.query.empty()) { ll.push_str("query"); - ll.push_str(u.query); + ll.push_str(uri.query); ll.set_table(); } - if (!u.fragment.empty()) + if (!uri.fragment.empty()) { ll.push_str("fragment"); - ll.push_str(u.fragment); + ll.push_str(uri.fragment); ll.set_table(); } } bool -lua_hooks::hook_get_netsync_connect_command(uri const & u, +lua_hooks::hook_get_netsync_connect_command(uri_t const & uri, globish const & include_pattern, globish const & exclude_pattern, bool debug, @@ -680,7 +680,7 @@ lua_hooks::hook_get_netsync_connect_comm Lua ll(st); ll.func("get_netsync_connect_command"); - push_uri(u, ll); + push_uri(uri, ll); ll.push_table(); @@ -721,12 +721,12 @@ bool bool -lua_hooks::hook_use_transport_auth(uri const & u) +lua_hooks::hook_use_transport_auth(uri_t const & uri) { bool use_auth = true; Lua ll(st); ll.func("use_transport_auth"); - push_uri(u, ll); + push_uri(uri, ll); ll.call(1,1); ll.extract_bool(use_auth); ============================================================ --- lua_hooks.hh 13b02250e084d7e1d04d9df095f4409d3b6189bb +++ lua_hooks.hh 66dc21dc1fad41f217c026729dda415d8051fdff @@ -22,7 +22,7 @@ #include "paths.hh" #include "commands.hh" -struct uri; +struct uri_t; class app_state; struct lua_State; struct globish; @@ -73,12 +73,12 @@ public: globish const & include, globish const & exclude, rsa_keypair_id & k); - bool hook_get_netsync_connect_command(uri const & u, + bool hook_get_netsync_connect_command(uri_t const & uri, globish const & include_pattern, globish const & exclude_pattern, bool debug, std::vector & argv); - bool hook_use_transport_auth(uri const & u); + bool hook_use_transport_auth(uri_t const & uri); bool hook_get_netsync_read_permitted(std::string const & branch, rsa_keypair_id const & identity); ============================================================ --- netcmd.hh 9fd97280633714008862a4a261403461d335fed5 +++ netcmd.hh 0dcc01c8e199edfc548f12a76a4adcf7b824a8bf @@ -188,7 +188,7 @@ struct netsync_connection_info { globish include_pattern; globish exclude_pattern; - uri u; + uri_t uri; utf8 unparsed; std::vector argv; bool use_argv; ============================================================ --- netsync.cc 8aa8a063c4a6a506a7e30d2e1ff85a38da445253 +++ netsync.cc 5fa0c7f976f5570e48a91edea6d085e15e6d7acf @@ -3082,11 +3082,11 @@ build_stream_to_server(options & opts, l #else bool use_ipv6=false; #endif - string host(info.client.u.host); + string host(info.client.uri.host); if (host.empty()) host = info.client.unparsed(); - if (!info.client.u.port.empty()) - default_port = lexical_cast(info.client.u.port); + if (!info.client.uri.port.empty()) + default_port = lexical_cast(info.client.uri.port); Netxx::Address addr(info.client.unparsed().c_str(), default_port, use_ipv6); return shared_ptr @@ -3196,7 +3196,7 @@ session_from_server_sync_item(options & info.client.include_pattern = globish(request.include, origin::user); info.client.exclude_pattern = globish(request.exclude, origin::user); info.client.use_argv = false; - parse_uri(info.client.unparsed(), info.client.u, + parse_uri(info.client.unparsed(), info.client.uri, origin::user /* from lua hook */); try ============================================================ --- unit-tests/uri.cc be871d7b14f2fd2c066b4759ae43abc2f2d08912 +++ unit-tests/uri.cc 6a59bc8b989d98385aee5ca69195d02bcfae7d7d @@ -77,18 +77,18 @@ test_one_uri(string scheme, } L(FL("testing parse of URI '%s'") % built); - uri u; - UNIT_TEST_CHECK_NOT_THROW(parse_uri(built, u, origin::user), recoverable_failure); - UNIT_TEST_CHECK(u.scheme == scheme); - UNIT_TEST_CHECK(u.user == user); + uri_t uri; + UNIT_TEST_CHECK_NOT_THROW(parse_uri(built, uri, origin::user), recoverable_failure); + UNIT_TEST_CHECK(uri.scheme == scheme); + UNIT_TEST_CHECK(uri.user == user); if (!normal_host.empty()) - UNIT_TEST_CHECK(u.host == normal_host); + UNIT_TEST_CHECK(uri.host == normal_host); else - UNIT_TEST_CHECK(u.host == ipv6_host); - UNIT_TEST_CHECK(u.port == port); - UNIT_TEST_CHECK(u.path == path); - UNIT_TEST_CHECK(u.query == query); - UNIT_TEST_CHECK(u.fragment == fragment); + UNIT_TEST_CHECK(uri.host == ipv6_host); + UNIT_TEST_CHECK(uri.port == port); + UNIT_TEST_CHECK(uri.path == path); + UNIT_TEST_CHECK(uri.query == query); + UNIT_TEST_CHECK(uri.fragment == fragment); } UNIT_TEST(basic) @@ -115,11 +115,11 @@ UNIT_TEST(invalid) UNIT_TEST(invalid) { - uri u; + uri_t uri; - UNIT_TEST_CHECK_THROW(parse_uri("http://[f3:03:21/foo/bar", u, origin::internal), unrecoverable_failure); - UNIT_TEST_CHECK_THROW(parse_uri("http://example.com:/foo/bar", u, origin::user), recoverable_failure); - UNIT_TEST_CHECK_THROW(parse_uri("http://example.com:1a4/foo/bar", u, origin::user), recoverable_failure); + UNIT_TEST_CHECK_THROW(parse_uri("http://[f3:03:21/foo/bar", uri, origin::internal), unrecoverable_failure); + UNIT_TEST_CHECK_THROW(parse_uri("http://example.com:/foo/bar", uri, origin::user), recoverable_failure); + UNIT_TEST_CHECK_THROW(parse_uri("http://example.com:1a4/foo/bar", uri, origin::user), recoverable_failure); } UNIT_TEST(urldecode) ============================================================ --- uri.cc 1c57c3a5fa0f0899e60e71b2b79caea4d1c3596d +++ uri.cc 33af93af2c742dd75d257121d1a62b105adc2582 @@ -15,7 +15,7 @@ static void typedef string::size_type stringpos; static void -parse_authority(string const & in, uri & u, origin::type made_from) +parse_authority(string const & in, uri_t & uri, origin::type made_from) { L(FL("matched URI authority: '%s'") % in); @@ -26,9 +26,9 @@ parse_authority(string const & in, uri & stringpos user_end = in.find('@', p); if (user_end != 0 && user_end < in.size()) { - u.user.assign(in, 0, user_end); + uri.user.assign(in, 0, user_end); p = user_end + 1; - L(FL("matched URI user: '%s'") % u.user); + L(FL("matched URI user: '%s'") % uri.user); } // The next thing must either be an ipv6 address, which has the form @@ -42,16 +42,16 @@ parse_authority(string const & in, uri & E(ipv6_end != string::npos, made_from, F("IPv6 address in URI has no closing ']'")); - u.host.assign(in, p, ipv6_end - p); + uri.host.assign(in, p, ipv6_end - p); p = ipv6_end + 1; - L(FL("matched URI host (IPv6 address): '%s'") % u.host); + L(FL("matched URI host (IPv6 address): '%s'") % uri.host); } else { stringpos host_end = in.find(':', p); - u.host.assign(in, p, host_end - p); + uri.host.assign(in, p, host_end - p); p = host_end; - L(FL("matched URI host: '%s'") % u.host); + L(FL("matched URI host: '%s'") % uri.host); } // Finally, if the host-part was ended by a colon, there is a port number @@ -65,21 +65,15 @@ parse_authority(string const & in, uri & E(in.find_first_not_of("0123456789", p) == string::npos, made_from, F("explicit port-number specification in URI contains nondigits")); - u.port.assign(in, p, string::npos); - L(FL("matched URI port: '%s'") % u.port); + uri.port.assign(in, p, string::npos); + L(FL("matched URI port: '%s'") % uri.port); } } void -parse_uri(string const & in, uri & u, origin::type made_from) +parse_uri(string const & in, uri_t & uri, origin::type made_from) { - u.scheme.clear(); - u.user.clear(); - u.host.clear(); - u.port.clear(); - u.path.clear(); - u.query.clear(); - u.fragment.clear(); + uri.clear(); stringpos p = 0; @@ -91,9 +85,9 @@ parse_uri(string const & in, uri & u, or if (scheme_end != 0 && scheme_end < in.size() && in.at(scheme_end) == ':') { - u.scheme.assign(in, p, scheme_end - p); + uri.scheme.assign(in, p, scheme_end - p); p = scheme_end + 1; - L(FL("matched URI scheme: '%s'") % u.scheme); + L(FL("matched URI scheme: '%s'") % uri.scheme); } // Next, there may be an authority: "//" followed by zero or more @@ -105,7 +99,7 @@ parse_uri(string const & in, uri & u, or stringpos authority_end = in.find_first_of("/?#", p); if (authority_end != p) { - parse_authority(string(in, p, authority_end - p), u, made_from); + parse_authority(string(in, p, authority_end - p), uri, made_from); p = authority_end; } if (p >= in.size()) @@ -115,9 +109,9 @@ parse_uri(string const & in, uri & u, or // Next, a path: zero or more characters which are not "?#". { stringpos path_end = in.find_first_of("?#", p); - u.path.assign(in, p, path_end - p); + uri.path.assign(in, p, path_end - p); p = path_end; - L(FL("matched URI path: '%s'") % u.path); + L(FL("matched URI path: '%s'") % uri.path); if (p >= in.size()) return; } @@ -128,9 +122,9 @@ parse_uri(string const & in, uri & u, or { p++; stringpos query_end = in.find('#', p); - u.query.assign(in, p, query_end - p); + uri.query.assign(in, p, query_end - p); p = query_end; - L(FL("matched URI query: '%s'") % u.query); + L(FL("matched URI query: '%s'") % uri.query); if (p >= in.size()) return; } @@ -139,8 +133,8 @@ parse_uri(string const & in, uri & u, or // is a fragment identifier. if (in.at(p) == '#') { - u.fragment.assign(in, p + 1, string::npos); - L(FL("matched URI fragment: '%s'") % u.fragment); + uri.fragment.assign(in, p + 1, string::npos); + L(FL("matched URI fragment: '%s'") % uri.fragment); } } ============================================================ --- uri.hh 4ee1882809ef881390a703fb31e2a41a3258c70c +++ uri.hh 9afc3c0849902ced57c34161c7a0e63ce6ca09da @@ -12,7 +12,7 @@ #include "sanity.hh" -struct uri +struct uri_t { std::string scheme; std::string user; @@ -21,10 +21,21 @@ struct uri std::string path; std::string query; std::string fragment; + + void clear() + { + scheme.clear(); + user.clear(); + host.clear(); + port.clear(); + path.clear(); + query.clear(); + fragment.clear(); + } }; void -parse_uri(std::string const & in, uri & out, origin::type made_from); +parse_uri(std::string const & in, uri_t & uri, origin::type made_from); std::string urldecode(std::string const & in, origin::type made_from);