From cdda603905ece7c48b08917f083e5f83dc10bb16 Mon Sep 17 00:00:00 2001 From: Youngmin Yoo Date: Thu, 5 Jan 2017 12:58:18 +0900 Subject: [PATCH] Fix URI scheme parsing 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 --- common/url.cc | 5 +++++ common/url.h | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/common/url.cc b/common/url.cc index adfbff1..898190c 100644 --- a/common/url.cc +++ b/common/url.cc @@ -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() { diff --git a/common/url.h b/common/url.h index 89ef348..222e738 100644 --- a/common/url.h +++ b/common/url.h @@ -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 */ -- 2.7.4