File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -404,14 +404,27 @@ impl Collection {
404404 . duration_since ( SystemTime :: UNIX_EPOCH )
405405 . unwrap ( ) ;
406406
407+ let sanitized_label = label
408+ . chars ( )
409+ . map ( |c| {
410+ if c. is_alphanumeric ( ) || c == '_' {
411+ c
412+ } else {
413+ '_'
414+ }
415+ } )
416+ . collect :: < String > ( ) ;
417+
407418 Self {
408419 items : Default :: default ( ) ,
409420 label : Arc :: new ( Mutex :: new ( label. to_owned ( ) ) ) ,
410421 modified : Arc :: new ( Mutex :: new ( created) ) ,
411422 alias : Arc :: new ( Mutex :: new ( alias. to_owned ( ) ) ) ,
412423 item_index : Arc :: new ( RwLock :: new ( 0 ) ) ,
413- path : OwnedObjectPath :: try_from ( format ! ( "/org/freedesktop/secrets/collection/{label}" ) )
414- . unwrap ( ) ,
424+ path : OwnedObjectPath :: try_from ( format ! (
425+ "/org/freedesktop/secrets/collection/{sanitized_label}"
426+ ) )
427+ . expect ( "Sanitized label should always produce valid object path" ) ,
415428 created,
416429 service,
417430 keyring : Arc :: new ( RwLock :: new ( Some ( keyring) ) ) ,
You can’t perform that action at this time.
0 commit comments