Parse a DN and return an array-ized one. This is not a validating parser and it does not support any old-stylish syntax; gpgme is expected to return only rfc2253 compatible strings. */
| 277 | parser and it does not support any old-stylish syntax; gpgme is |
| 278 | expected to return only rfc2253 compatible strings. */ |
| 279 | static Result parseString(std::string_view string) |
| 280 | { |
| 281 | Result result; |
| 282 | while (!string.empty()) { |
| 283 | string = detail::removeLeadingSpaces(string); |
| 284 | if (string.empty()) { |
| 285 | break; |
| 286 | } |
| 287 | |
| 288 | auto [partResult, dnPair] = detail::parse_dn_part(string); |
| 289 | if (!partResult.has_value()) { |
| 290 | return {}; |
| 291 | } |
| 292 | |
| 293 | string = partResult.value(); |
| 294 | if (dnPair.first.size() && dnPair.second.size()) { |
| 295 | result.emplace_back(std::move(dnPair)); |
| 296 | } |
| 297 | |
| 298 | string = detail::removeLeadingSpaces(string); |
| 299 | if (string.empty()) { |
| 300 | break; |
| 301 | } |
| 302 | switch (string.front()) { |
| 303 | case ',': |
| 304 | case ';': |
| 305 | case '+': |
| 306 | string.remove_prefix(1); |
| 307 | break; |
| 308 | default: |
| 309 | // some unexpected characters here |
| 310 | return {}; |
| 311 | } |
| 312 | } |
| 313 | return result; |
| 314 | } |
| 315 | |
| 316 | /// returns the first value of a given key (note. there can be multiple) |
| 317 | /// or nullopt if key is not available |
no test coverage detected