From ca055f9337c86603273e7b52a2cb7556b6343e58 Mon Sep 17 00:00:00 2001 From: WonYoung Choi Date: Tue, 8 Dec 2015 10:15:24 +0900 Subject: [PATCH] Use glib uri functions instead of libcurl to encode/decode uri. Use glib uri functions to remove libcurl dependency. The glib uri functions provides enough functionalities to encode/deocde uri. --- common/common.gyp | 1 - common/resource_manager.cc | 6 +++--- common/string_utils.cc | 24 ++++-------------------- packaging/crosswalk-tizen.spec | 1 - 4 files changed, 7 insertions(+), 25 deletions(-) diff --git a/common/common.gyp b/common/common.gyp index 9826187..7cdae87 100644 --- a/common/common.gyp +++ b/common/common.gyp @@ -48,7 +48,6 @@ 'dlog', 'gio-2.0', 'uuid', - 'libcurl', 'libwebappenc', 'manifest-parser', 'manifest-handlers', diff --git a/common/resource_manager.cc b/common/resource_manager.cc index fdd6fd9..74e95a4 100644 --- a/common/resource_manager.cc +++ b/common/resource_manager.cc @@ -316,7 +316,7 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) { if (utils::StartsWith(url, check)) { url.erase(0, check.length()); } else { - LOGGER(ERROR) << "Invalid appid"; + LOGGER(ERROR) << "Invalid uri: {scheme:app} uri=" << origin; return result; } } else if (utils::StartsWith(url, file_scheme)) { @@ -329,7 +329,7 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) { } if (url.empty()) { - LOGGER(ERROR) << "URL Localization error"; + LOGGER(ERROR) << "Invalid uri: uri=" << origin; return result; } @@ -359,7 +359,7 @@ std::string ResourceManager::GetLocalizedPath(const std::string& origin) { return result; } - LOGGER(ERROR) << "URL Localization error"; + LOGGER(ERROR) << "Invalid uri: uri=" << origin << ", decoded=" << file_path; return result; } diff --git a/common/string_utils.cc b/common/string_utils.cc index 5036524..c2b0fc3 100644 --- a/common/string_utils.cc +++ b/common/string_utils.cc @@ -16,7 +16,6 @@ #include "common/string_utils.h" -#include #include #include #include @@ -32,11 +31,6 @@ namespace common { namespace utils { -namespace { -std::unique_ptr - g_curl {nullptr, curl_easy_cleanup}; -} // namespace - std::string GenerateUUID() { char tmp[37]; uuid_t uuid; @@ -90,24 +84,14 @@ bool SplitString(const std::string &str, } std::string UrlDecode(const std::string& url) { - if (g_curl.get() == nullptr) { - g_curl.reset(curl_easy_init()); - } - std::unique_ptr decoded_str { - curl_easy_unescape(g_curl.get(), url.c_str(), url.length(), NULL), - curl_free }; - + std::unique_ptr decoded_str { + g_uri_unescape_string(url.c_str(), NULL), std::free }; return decoded_str.get() != nullptr ? std::string(decoded_str.get()) : url; } std::string UrlEncode(const std::string& url) { - if (g_curl.get() == nullptr) { - g_curl.reset(curl_easy_init()); - } - std::unique_ptr encoded_str { - curl_easy_escape(g_curl.get(), url.c_str(), url.length()), - curl_free }; - + std::unique_ptr encoded_str { + g_uri_escape_string(url.c_str(), NULL, TRUE), std::free }; return encoded_str.get() != nullptr ? std::string(encoded_str.get()) : url; } diff --git a/packaging/crosswalk-tizen.spec b/packaging/crosswalk-tizen.spec index 0104426..4b09997 100644 --- a/packaging/crosswalk-tizen.spec +++ b/packaging/crosswalk-tizen.spec @@ -42,7 +42,6 @@ BuildRequires: pkgconfig(efl-extension) BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libwebappenc) BuildRequires: pkgconfig(manifest-handlers) BuildRequires: pkgconfig(manifest-parser) -- 2.7.4