Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/miniocpp/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ std::string Join(const std::vector<std::string>& values,
// EncodePath does URL encoding of path. It also normalizes multiple slashes.
std::string EncodePath(const std::string& path);

// XMLEncode does XML encoding of value.
std::string XMLEncode(const std::string& value);

// Sha256hash computes SHA-256 of data and return hash as hex encoded value.
std::string Sha256Hash(std::string_view str);

Expand Down
2 changes: 1 addition & 1 deletion src/baseclient.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1459,7 +1459,7 @@ RemoveObjectsResponse BaseClient::RemoveObjects(RemoveObjectsApiArgs args) {
if (args.quiet) ss << "<Quiet>true</Quiet>";
for (auto& object : args.objects) {
ss << "<Object>";
ss << "<Key>" << object.name << "</Key>";
ss << "<Key>" << utils::XMLEncode(object.name) << "</Key>";
if (!object.version_id.empty()) {
ss << "<VersionId>" << object.version_id << "</VersionId>";
}
Expand Down
9 changes: 9 additions & 0 deletions src/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <string>
#include <type_traits>
#include <vector>
#include <pugixml.hpp>

namespace minio::utils {

Expand Down Expand Up @@ -222,6 +223,14 @@ std::string EncodePath(const std::string& path) {
return out;
}

std::string XMLEncode(const std::string& value) {
pugi::xml_document doc;
doc.append_child(pugi::node_pcdata).set_value(value);
std::ostringstream out;
doc.print(out);
return out.str();
}

std::string Sha256Hash(std::string_view str) {
EVP_MD_CTX* ctx = EVP_MD_CTX_create();
if (ctx == nullptr) {
Expand Down
Loading