aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-07-16 16:34:22 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-07-16 16:34:22 -0700
commitc9af31dad084f3fb58a7523e0bcf917a1d98cf3e (patch)
treecb98c1d7e3b448fd9735ee6cb5c2320d23c6604b
parent9a3f858f9316cf8acca4aa964a35a784a93d7a17 (diff)
parent275a02c317d3c204b216aab5f7c7e74852c6ff60 (diff)
Merge pull request #2473 from hongweiwang/uri_parser
Fix authority in uri_parser
-rw-r--r--src/core/client_config/uri_parser.c2
-rw-r--r--test/core/client_config/uri_parser_test.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/src/core/client_config/uri_parser.c b/src/core/client_config/uri_parser.c
index 776a255923..410a61c8cf 100644
--- a/src/core/client_config/uri_parser.c
+++ b/src/core/client_config/uri_parser.c
@@ -98,7 +98,7 @@ grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors) {
if (uri_text[scheme_end + 1] == '/' && uri_text[scheme_end + 2] == '/') {
authority_begin = scheme_end + 3;
- for (i = authority_begin; uri_text[i] != 0; i++) {
+ for (i = authority_begin; uri_text[i] != 0 && authority_end == -1; i++) {
if (uri_text[i] == '/') {
authority_end = i;
}
diff --git a/test/core/client_config/uri_parser_test.c b/test/core/client_config/uri_parser_test.c
index e5f9017ce0..3451ca1e8c 100644
--- a/test/core/client_config/uri_parser_test.c
+++ b/test/core/client_config/uri_parser_test.c
@@ -60,6 +60,7 @@ int main(int argc, char **argv) {
test_succeeds("http://www.google.com:90", "http", "www.google.com:90", "");
test_succeeds("a192.4-df:foo.coom", "a192.4-df", "", "foo.coom");
test_succeeds("a+b:foo.coom", "a+b", "", "foo.coom");
+ test_succeeds("zookeeper://127.0.0.1:2181/foo/bar", "zookeeper", "127.0.0.1:2181", "/foo/bar");
test_fails("xyz");
test_fails("http://www.google.com?why-are-you-using-queries");
test_fails("dns:foo.com#fragments-arent-supported-here");