5 #include <common/errno.h>
6 #include <boost/algorithm/string.hpp>
10 static constexpr uint32_t MAX_OBJ_TAGS=10;
11 static constexpr uint32_t MAX_TAG_KEY_SIZE=128;
12 static constexpr uint32_t MAX_TAG_VAL_SIZE=256;
14 bool RGWObjTags::add_tag(const string&key, const string& val){
15 return tag_map.emplace(std::make_pair(key,val)).second;
18 int RGWObjTags::check_and_add_tag(const string&key, const string& val){
19 if (tag_map.size() == MAX_OBJ_TAGS ||
20 key.size() > MAX_TAG_KEY_SIZE ||
21 val.size() > MAX_TAG_VAL_SIZE ||
23 return -ERR_INVALID_TAG;
26 // if we get a conflicting key, either the XML is malformed or the user
27 // supplied an invalid string
28 if (!add_tag(key,val))
34 int RGWObjTags::set_from_string(const string& input){
37 boost::split(kvs, input, boost::is_any_of("&"));
38 for (const auto& kv: kvs){
39 auto p = kv.find("=");
41 if (p != string::npos) {
42 ret = check_and_add_tag(url_decode(kv.substr(0,p)),
43 url_decode(kv.substr(p+1)));
45 ret = check_and_add_tag(url_decode(kv));