summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/Url.cpp
diff options
context:
space:
mode:
authorStephen D. Huston <shuston@apache.org>2011-10-21 14:42:12 +0000
committerStephen D. Huston <shuston@apache.org>2011-10-21 14:42:12 +0000
commitf83677056891e436bf5ba99e79240df2a44528cd (patch)
tree625bfd644b948e89105630759cf6decb0435354d /cpp/src/qpid/Url.cpp
parentebfd9ff053b04ab379acfc0fefedee5a31b6d8a5 (diff)
downloadqpid-python-QPID-2519.tar.gz
Merged out from trunkQPID-2519
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-2519@1187375 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/Url.cpp')
-rw-r--r--cpp/src/qpid/Url.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/cpp/src/qpid/Url.cpp b/cpp/src/qpid/Url.cpp
index ab796f4642..f699b60c17 100644
--- a/cpp/src/qpid/Url.cpp
+++ b/cpp/src/qpid/Url.cpp
@@ -156,11 +156,12 @@ class UrlParser {
return false;
}
- // TODO aconway 2008-11-20: this does not fully implement
- // http://www.ietf.org/rfc/rfc3986.txt. Works for DNS names and
- // ipv4 literals but won't handle ipv6.
+ // A liberal interpretation of http://www.ietf.org/rfc/rfc3986.txt.
+ // Works for DNS names and and ipv4 and ipv6 literals
//
bool host(string& h) {
+ if (ip6literal(h)) return true;
+
const char* start=i;
while (unreserved() || pctEncoded())
;
@@ -169,6 +170,22 @@ class UrlParser {
return true;
}
+ // This is a bit too liberal for IPv6 literal addresses, but probably good enough
+ bool ip6literal(string& h) {
+ if (literal("[")) {
+ const char* start = i;
+ while (hexDigit() || literal(":") || literal("."))
+ ;
+ const char* end = i;
+ if ( end-start < 2 ) return false; // Smallest valid address is "::"
+ if (literal("]")) {
+ h.assign(start, end);
+ return true;
+ }
+ }
+ return false;
+ }
+
bool unreserved() { return (::isalnum(*i) || ::strchr("-._~", *i)) && advance(); }
bool pctEncoded() { return literal("%") && hexDigit() && hexDigit(); }