Fix URI scheme parsing 41/108541/2
authorYoungmin Yoo <youngmin.yoo@samsung.com>
Thu, 5 Jan 2017 03:58:18 +0000 (12:58 +0900)
committerYoungmin Yoo <youngmin.yoo@samsung.com>
Thu, 5 Jan 2017 04:13:38 +0000 (13:13 +0900)
IP/Host on the internet
ex) http://user:password@www.tizen.org:8080/market/Item?12345
    url_ = http://user:password@www.tizen.org:8080/market/Item?12345
    scheme_ = http
    domain_ = www.tizen.org
    user_ = user
    password_ = password

Link : https://www.w3.org/Addressing/rfc1738.txt
Bug : P161229-04063
Bug : http://suprem.sec.samsung.net/jira/browse/TWF-2753

Change-Id: I71fbc95c5b71cd36c370c3ed34fe6d8176cb21a7
Signed-off-by: Youngmin Yoo <youngmin.yoo@samsung.com>
common/url.cc
common/url.h

index adfbff1..898190c 100644 (file)
@@ -109,9 +109,14 @@ void URLImpl::ExtractDomain() {
   size_t start_of_domain = scheme_.empty() ?
                            0 : scheme_.length() + kSchemeIdLen;
   size_t end_of_domain = url_.find_first_of('/', start_of_domain);
+  size_t at = url_.find_first_of('@', start_of_domain);
+  if (at < end_of_domain) {
+    start_of_domain = at + 1;
+  }
   domain_ =
     url_.substr(start_of_domain, end_of_domain == std::string::npos ?
                 std::string::npos : end_of_domain - start_of_domain);
+  LOGGER(INFO) << "Extract Domain is " << domain_;
 }
 
 void URLImpl::ExtractDomainPort() {
index 89ef348..222e738 100644 (file)
@@ -38,12 +38,14 @@ class URLImpl;
  *   => domain_, path_
  *
  * If the url does not have specific data, an empty string will be stored
- * in the corresponding variables.
+ * in the corresponding variables.(RFC 1738)
  *
- * ex) http://user:password@www.google.co.kr:8080/market/Item?12345
- * url_ = http://user:password@www.google.co.kr:8080/market/Item?12345
+ * ex) http://user:password@www.tizen.org:8080/market/Item?12345
+ * url_ = http://user:password@www.tizen.org:8080/market/Item?12345
  * scheme_ = http
- * domain_ = user:password@www.google.co.kr
+ * user_ = user
+ * password_ = password
+ * domain_ = www.tizen.org
  * port_ = 8080
  * path_ = /market/Item?12345
 */