@@ -451,7 +451,7 @@ StreamListSource::next(std::string& name, int64_t& size)
451451}
452452
453453static void
454- recode_label (std::string& label, uint64_t & expiry)
454+ recode_label (libcdoc::Recipient& rcpt, std::string& label, uint64_t & expiry)
455455{
456456 if (!label.starts_with (" data:" )) return ;
457457 auto values = libcdoc::Lock::parseLabel (label);
@@ -463,40 +463,39 @@ recode_label(std::string& label, uint64_t& expiry)
463463 std::string expiry_str = values.at (" server_exp" );
464464 values.erase (" server_exp" );
465465 if (!expiry_str.empty ()) expiry = std::stoll (expiry_str);
466- QUrlQuery q;
467- q.setQueryItems ({
468- {QStringLiteral (" v" ), QString::number (1 )},
469- {QStringLiteral (" type" ), QString::fromStdString (type)}
470- });
471466 for (const auto & [key, value] : values) {
472467 if (!value.empty ())
473- q. addQueryItem ( QString::fromStdString ( key), QString::fromStdString ( value) );
468+ rcpt. setLabelValue ( key, value);
474469 }
475- label = " data:" + q.query (QUrl::FullyEncoded).toStdString ();
476470}
477471
478472libcdoc::Recipient
479473makeFromLock (const libcdoc::Lock& lock, const std::string& server_id)
480474{
481475 uint64_t expiry_ts = 0 ;
482476 std::string label = lock.label ;
483- recode_label (label, expiry_ts);
484477 switch (lock.type ) {
485478 case libcdoc::Lock::CDOC1:
486479 if (!server_id.empty ()) {
487- return libcdoc::Recipient::makeServer (label, lock.getBytes (libcdoc::Lock::CERT), server_id);
480+ libcdoc::Recipient rcpt = libcdoc::Recipient::makeServer (label, lock.getBytes (libcdoc::Lock::CERT), server_id);
481+ recode_label (rcpt, label, expiry_ts);
482+ return rcpt;
488483 } else {
489- return libcdoc::Recipient::makeCertificate (label, lock.getBytes (libcdoc::Lock::CERT));
484+ libcdoc::Recipient rcpt = libcdoc::Recipient::makeCertificate (label, lock.getBytes (libcdoc::Lock::CERT));
485+ recode_label (rcpt, label, expiry_ts);
486+ return rcpt;
490487 }
491488 case libcdoc::Lock::PUBLIC_KEY:
492489 case libcdoc::Lock::SERVER: {
493490 libcdoc::Recipient::PKType rcpt_type = (lock.pk_type == libcdoc::Lock::RSA) ? libcdoc::Recipient::RSA : libcdoc::Recipient::ECC;
494491 if (!server_id.empty ()) {
495492 libcdoc::Recipient rcpt = libcdoc::Recipient::makeServer (label, lock.getBytes (libcdoc::Lock::RCPT_KEY), rcpt_type, server_id);
493+ recode_label (rcpt, label, expiry_ts);
496494 rcpt.expiry_ts = expiry_ts;
497495 return rcpt;
498496 } else {
499497 libcdoc::Recipient rcpt = libcdoc::Recipient::makePublicKey (label, lock.getBytes (libcdoc::Lock::RCPT_KEY), rcpt_type);
498+ recode_label (rcpt, label, expiry_ts);
500499 rcpt.expiry_ts = expiry_ts;
501500 return rcpt;
502501 }
0 commit comments