summaryrefslogtreecommitdiff
path: root/src/mongo/client
diff options
context:
space:
mode:
authorBilly Donahue <billy.donahue@mongodb.com>2020-09-09 21:32:04 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2020-09-15 00:42:05 +0000
commit58828b0ce9556ee9cb38c484d1226663a0dcd993 (patch)
treedfea448799d9bd4328114199a9767dd18d045be3 /src/mongo/client
parent22a77301a5b63b9bb7ef6dd73eabb4865c63a921 (diff)
downloadmongo-58828b0ce9556ee9cb38c484d1226663a0dcd993.tar.gz
SERVER-43909 clarify and repair util/hex.h API
- hexblob namespace - Throwy hexblob::decode (nee fromHex) - StringData overloads of hex codec ops - add unsignedHex<T> and zeroPaddedHex<T>
Diffstat (limited to 'src/mongo/client')
-rw-r--r--src/mongo/client/mongo_uri.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/mongo/client/mongo_uri.cpp b/src/mongo/client/mongo_uri.cpp
index d9153cb3c02..ae8322c086c 100644
--- a/src/mongo/client/mongo_uri.cpp
+++ b/src/mongo/client/mongo_uri.cpp
@@ -46,6 +46,7 @@
#include "mongo/db/auth/sasl_command_constants.h"
#include "mongo/db/namespace_string.h"
#include "mongo/stdx/utility.h"
+#include "mongo/util/assert_util.h"
#include "mongo/util/dns_name.h"
#include "mongo/util/dns_query.h"
#include "mongo/util/hex.h"
@@ -85,24 +86,22 @@ void mongo::uriEncode(std::ostream& ss, StringData toEncode, StringData passthro
mongo::StatusWith<std::string> mongo::uriDecode(StringData toDecode) {
StringBuilder out;
for (size_t i = 0; i < toDecode.size(); ++i) {
- const char c = toDecode[i];
+ char c = toDecode[i];
if (c == '%') {
if (i + 2 >= toDecode.size()) {
return Status(ErrorCodes::FailedToParse,
"Encountered partial escape sequence at end of string");
}
- auto swHex = fromHex(toDecode.substr(i + 1, 2));
- if (swHex.isOK()) {
- out << swHex.getValue();
- } else {
+ try {
+ c = hexblob::decodePair(toDecode.substr(i + 1, 2));
+ } catch (const ExceptionFor<ErrorCodes::FailedToParse>&) {
return Status(ErrorCodes::Error(51040),
"The characters after the % do not form a hex value. Please escape "
"the % or pass a valid hex value. ");
}
i += 2;
- } else {
- out << c;
}
+ out << c;
}
return out.str();
}