Commit 6694eb62 authored by Diogo Silva's avatar Diogo Silva
Browse files

Utility: reformated and changed C-style cast to static_cast

parent 9c47d860
......@@ -23,11 +23,11 @@
#include "Utility.h"
#include <json/json.h>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <json/json.h>
#include <sstream>
#include <unordered_map>
......@@ -110,11 +110,10 @@ std::string Url::unescape(const std::string& value) {
for (int i = 0; i < value.length(); i++) {
if (value[i] == '%') {
// Failed to unescape (there is not enough digits with the %
if (i >= value.length() - 2)
return "";
if (i >= value.length() - 2) return "";
sscanf(value.substr(i + 1, 2).c_str(), "%x", &hex_extract);
unescaped << hex_extract;
i += 2; // Skip the two elements that were read
i += 2; // Skip the two elements that were read
} else {
unescaped << value[i];
}
......@@ -134,7 +133,7 @@ std::string Url::escape(const std::string& value) {
continue;
}
escaped << std::uppercase;
escaped << '%' << std::setw(2) << int((unsigned char) c);
escaped << '%' << std::setw(2) << int(static_cast<unsigned char>(c));
escaped << std::nouppercase;
}
return escaped.str();
......@@ -143,5 +142,5 @@ std::string Url::escape(const std::string& value) {
std::string Url::escapeHeader(const std::string& header) {
return Json::valueToQuotedString(header.c_str());
}
} // namespace util
} // namespace cloudstorage
} // namespace util
} // namespace cloudstorage
......@@ -47,7 +47,7 @@ std::string address(const std::string& url, uint16_t port);
std::string to_mime_type(const std::string& extension);
class Url {
public:
public:
static std::string unescape(const std::string&);
static std::string escape(const std::string&);
static std::string escapeHeader(const std::string&);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment