@@ -386,23 +386,26 @@ impl Collection {
386386 ) -> zbus:: Result < ( ) > ;
387387}
388388
389+ fn collection_path ( label : & str ) -> Result < OwnedObjectPath , zvariant:: Error > {
390+ let sanitized_label = label. replace ( |c : char | !c. is_ascii_alphanumeric ( ) && c != '_' , "_" ) ;
391+
392+ OwnedObjectPath :: try_from ( format ! (
393+ "/org/freedesktop/secrets/collection/{sanitized_label}"
394+ ) )
395+ }
396+
389397impl Collection {
390398 pub async fn new ( label : & str , alias : & str , service : Service , keyring : Keyring ) -> Self {
391399 let modified = keyring. modified_time ( ) . await ;
392400 let created = keyring. created_time ( ) . await . unwrap_or ( modified) ;
393401
394- let sanitized_label = label. replace ( |c : char | !c. is_ascii_alphanumeric ( ) && c != '_' , "_" ) ;
395-
396402 Self {
397403 items : Default :: default ( ) ,
398404 label : Arc :: new ( Mutex :: new ( label. to_owned ( ) ) ) ,
399405 modified : Arc :: new ( Mutex :: new ( modified) ) ,
400406 alias : Arc :: new ( Mutex :: new ( alias. to_owned ( ) ) ) ,
401407 item_index : Arc :: new ( RwLock :: new ( 0 ) ) ,
402- path : OwnedObjectPath :: try_from ( format ! (
403- "/org/freedesktop/secrets/collection/{sanitized_label}"
404- ) )
405- . expect ( "Sanitized label should always produce valid object path" ) ,
408+ path : collection_path ( label) . expect ( "Label should produce a valid object path" ) ,
406409 created,
407410 service,
408411 keyring : Arc :: new ( RwLock :: new ( Some ( keyring) ) ) ,
0 commit comments