File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,6 +95,9 @@ std::string Join(const std::vector<std::string>& values,
9595// EncodePath does URL encoding of path. It also normalizes multiple slashes.
9696std::string EncodePath (const std::string& path);
9797
98+ // XMLEncode does XML encoding of value.
99+ std::string XMLEncode (const std::string& value);
100+
98101// Sha256hash computes SHA-256 of data and return hash as hex encoded value.
99102std::string Sha256Hash (std::string_view str);
100103
Original file line number Diff line number Diff line change @@ -1459,7 +1459,7 @@ RemoveObjectsResponse BaseClient::RemoveObjects(RemoveObjectsApiArgs args) {
14591459 if (args.quiet ) ss << " <Quiet>true</Quiet>" ;
14601460 for (auto & object : args.objects ) {
14611461 ss << " <Object>" ;
1462- ss << " <Key>" << object.name << " </Key>" ;
1462+ ss << " <Key>" << utils::XMLEncode ( object.name ) << " </Key>" ;
14631463 if (!object.version_id .empty ()) {
14641464 ss << " <VersionId>" << object.version_id << " </VersionId>" ;
14651465 }
Original file line number Diff line number Diff line change 5656#include < map>
5757#include < memory>
5858#include < ostream>
59+ #include < pugixml.hpp>
5960#include < regex>
6061#include < sstream>
6162#include < streambuf>
@@ -222,6 +223,14 @@ std::string EncodePath(const std::string& path) {
222223 return out;
223224}
224225
226+ std::string XMLEncode (const std::string& value) {
227+ pugi::xml_document doc;
228+ doc.append_child (pugi::node_pcdata).set_value (value);
229+ std::ostringstream out;
230+ doc.print (out);
231+ return out.str ();
232+ }
233+
225234std::string Sha256Hash (std::string_view str) {
226235 EVP_MD_CTX* ctx = EVP_MD_CTX_create ();
227236 if (ctx == nullptr ) {
You can’t perform that action at this time.
0 commit comments