diff --git a/cdoc/Recipient.cpp b/cdoc/Recipient.cpp index 7772e87f..05f2c8c7 100644 --- a/cdoc/Recipient.cpp +++ b/cdoc/Recipient.cpp @@ -181,7 +181,7 @@ Recipient::getLabel(std::map extra) const break; case SYMMETRIC_KEY: case PUBLIC_KEY: - ofs << CDoc2::LABELPREFIX + ofs << CDoc2::LABELPREFIX << ',' << CDoc2::Label::VERSION << '=' << std::to_string(CDoc2::KEYLABELVERSION); for (const auto& [key, value] : lbl_parts) { if (key == "v") diff --git a/cdoc/Utils.cpp b/cdoc/Utils.cpp index 33527c75..dff69945 100644 --- a/cdoc/Utils.cpp +++ b/cdoc/Utils.cpp @@ -142,6 +142,10 @@ operator<<(std::ostream& escaped, urlEncode src) escaped << std::hex; for (auto c : src.src) { + if (c == ' ') { + escaped << '+'; + continue; + } // Keep alphanumeric and other accepted characters intact if (isalnum(c) || c == '-' || c == '_' || c == '.' || c == '~') { escaped << c; diff --git a/cdoc/Utils.h b/cdoc/Utils.h index f1df95b8..4e86400a 100644 --- a/cdoc/Utils.h +++ b/cdoc/Utils.h @@ -161,12 +161,21 @@ urlDecode(std::string_view src) uint8_t value = 0; for (auto it = src.cbegin(), end = src.cend(); it != end; ++it) { - if (*it == '%' && fromHex(it + 1, end, value)) { - ret += char(value); - std::advance(it, 2); - continue; + switch (*it) + { + case '+': + ret += ' '; + break; + case '%': + if (fromHex(it + 1, end, value)) { + ret += char(value); + std::advance(it, 2); + continue; + } + [[fallthrough]]; + default: + ret += *it; } - ret += *it; } return ret;