projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixes: prevent compiler reporting UB, hazptr_array move operator, empty array test
[folly.git]
/
folly
/
Uri.cpp
diff --git
a/folly/Uri.cpp
b/folly/Uri.cpp
index f4618d8750b792785a36dca071e235611cd53297..d1bdfae73b736c1d59bc0bb5e8f357a71c1f7281 100644
(file)
--- a/
folly/Uri.cpp
+++ b/
folly/Uri.cpp
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
4
Facebook, Inc.
+ * Copyright 201
7
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-16,28
+16,29
@@
#include <folly/Uri.h>
#include <folly/Uri.h>
-#include <ctype.h>
+#include <cctype>
+
#include <boost/regex.hpp>
namespace folly {
namespace {
#include <boost/regex.hpp>
namespace folly {
namespace {
-
fbstring submatch(const boost::cmatch& m, size_
t idx) {
+
std::string submatch(const boost::cmatch& m, in
t idx) {
auto& sub = m[idx];
auto& sub = m[idx];
- return
fb
string(sub.first, sub.second);
+ return
std::
string(sub.first, sub.second);
}
template <class String>
void toLower(String& s) {
for (auto& c : s) {
}
template <class String>
void toLower(String& s) {
for (auto& c : s) {
- c =
tolower(c
);
+ c =
char(tolower(c)
);
}
}
}
}
-}
// namespace
+} // namespace
-Uri::Uri(StringPiece str) : port_(0) {
+Uri::Uri(StringPiece str) :
hasAuthority_(false),
port_(0) {
static const boost::regex uriRegex(
"([a-zA-Z][a-zA-Z0-9+.-]*):" // scheme:
"([^?#]*)" // authority and path
static const boost::regex uriRegex(
"([a-zA-Z][a-zA-Z0-9+.-]*):" // scheme:
"([^?#]*)" // authority and path
@@
-60,7
+61,8
@@
Uri::Uri(StringPiece str) : port_(0) {
authorityAndPathMatch,
authorityAndPathRegex)) {
// Does not start with //, doesn't have authority
authorityAndPathMatch,
authorityAndPathRegex)) {
// Does not start with //, doesn't have authority
- path_ = authorityAndPath.fbstr();
+ hasAuthority_ = false;
+ path_ = authorityAndPath.str();
} else {
static const boost::regex authorityRegex(
"(?:([^@:]*)(?::([^@]*))?@)?" // username, password
} else {
static const boost::regex authorityRegex(
"(?:([^@:]*)(?::([^@]*))?@)?" // username, password
@@
-84,6
+86,7
@@
Uri::Uri(StringPiece str) : port_(0) {
port_ = to<uint16_t>(port);
}
port_ = to<uint16_t>(port);
}
+ hasAuthority_ = true;
username_ = submatch(authorityMatch, 1);
password_ = submatch(authorityMatch, 2);
host_ = submatch(authorityMatch, 3);
username_ = submatch(authorityMatch, 1);
password_ = submatch(authorityMatch, 2);
host_ = submatch(authorityMatch, 3);
@@
-94,8
+97,8
@@
Uri::Uri(StringPiece str) : port_(0) {
fragment_ = submatch(match, 4);
}
fragment_ = submatch(match, 4);
}
-
fb
string Uri::authority() const {
-
fb
string result;
+
std::
string Uri::authority() const {
+
std::
string result;
// Port is 5 characters max and we have up to 3 delimiters.
result.reserve(host().size() + username().size() + password().size() + 8);
// Port is 5 characters max and we have up to 3 delimiters.
result.reserve(host().size() + username().size() + password().size() + 8);
@@
-121,7
+124,7
@@
fbstring Uri::authority() const {
return result;
}
return result;
}
-
fb
string Uri::hostname() const {
+
std::
string Uri::hostname() const {
if (host_.size() > 0 && host_[0] == '[') {
// If it starts with '[', then it should end with ']', this is ensured by
// regex
if (host_.size() > 0 && host_[0] == '[') {
// If it starts with '[', then it should end with ']', this is ensured by
// regex
@@
-130,7
+133,7
@@
fbstring Uri::hostname() const {
return host_;
}
return host_;
}
-const std::vector<std::pair<
fbstring, fb
string>>& Uri::getQueryParams() {
+const std::vector<std::pair<
std::string, std::
string>>& Uri::getQueryParams() {
if (!query_.empty() && queryParams_.empty()) {
// Parse query string
static const boost::regex queryParamRegex(
if (!query_.empty() && queryParams_.empty()) {
// Parse query string
static const boost::regex queryParamRegex(
@@
-148,12
+151,12
@@
const std::vector<std::pair<fbstring, fbstring>>& Uri::getQueryParams() {
continue;
}
queryParams_.emplace_back(
continue;
}
queryParams_.emplace_back(
-
fb
string((*itr)[2].first, (*itr)[2].second), // parameter name
-
fb
string((*itr)[3].first, (*itr)[3].second) // parameter value
+
std::
string((*itr)[2].first, (*itr)[2].second), // parameter name
+
std::
string((*itr)[3].first, (*itr)[3].second) // parameter value
);
}
}
return queryParams_;
}
);
}
}
return queryParams_;
}
-}
// namespace folly
+} // namespace folly