Files
flipper/xplat/Flipper/FlipperURLSerializer.cpp
Lorenzo Blasa f3b0c82f4d Remove custom url_encode in favour of folly uri encode
Summary:
^
There was an issue for some characters in newer android API versions. One option was to fix our implementation, which can be done by casting to char to unsigned int before using std::isalnum.

But, do not duplicate existing functionality, used a solid implementation instead.

Changelog: Fixes an issue whereas the url encoding was incorrect for UTF-8

Reviewed By: mweststrate

Differential Revision: D33405760

fbshipit-source-id: e1c0a4da3dceb27e923b26d0ebfac091febeceb3
2022-01-05 04:06:43 -08:00

49 lines
1.0 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "FlipperURLSerializer.h"
#include <iomanip>
#include <sstream>
#include "FlipperBase64.h"
namespace facebook {
namespace flipper {
void URLSerializer::put(std::string key, std::string value) {
object_[key] = value;
}
void URLSerializer::put(std::string key, int value) {
object_[key] = value;
}
std::string URLSerializer::serialize() {
std::string query = "";
bool append = false;
for (auto& pair : object_.items()) {
auto key = pair.first.asString();
auto value = pair.second.asString();
if (append) {
query += "&";
}
query += key;
query += "=";
if (key == "csr") {
query += Base64::encode(value);
} else {
query +=
folly::uriEscape<std::string>(value, folly::UriEscapeMode::QUERY);
}
append = true;
}
return query;
}
} // namespace flipper
} // namespace facebook