File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -433,8 +433,8 @@ def unique_id(use_uuid)
433433
434434 ##
435435 # Generate a file name for exporting this note to an HTML file
436- def title_as_filename ( ext = '' , use_uuid : false )
437- file_title = title ? title . tr ( '/: ' , '_' ) : "Untitled"
436+ def title_as_filename ( ext = '' , use_uuid = false )
437+ file_title = title ? title . tr ( '[\\/*"<>?|:]\' ' , '_' ) : "Untitled"
438438 "#{ unique_id ( use_uuid ) } - #{ file_title } #{ ext } "
439439 end
440440
Original file line number Diff line number Diff line change 510510 tmp_note . add_cloudkit_server_record_data ( binary_plist )
511511 expect ( tmp_note . generate_html . text ) . to include ( "CloudKit Last Modified Device: Tester’s iPhone" )
512512 end
513+
514+ it "removes troublesome characters when using the title as a filename" do
515+ bad_title = AppleNote . new ( 3 ,
516+ 22 ,
517+ "Busted[Title], Do not use?\' \/ *<>?|:\' " ,
518+ File . read ( TEST_BLOB_DATA_DIR + "simple_note_protobuf_gzipped.bin" ) ,
519+ 608413790 ,
520+ 608413790 ,
521+ tmp_account ,
522+ tmp_folder )
523+ bad_title . uuid = note_uuid
524+ expect ( bad_title . title_as_filename ( '' , false ) ) . to eq "#{ bad_title . note_id } - Busted_Title_, Do not use__________"
525+ expect ( bad_title . title_as_filename ( '.html' , false ) ) . to eq "#{ bad_title . note_id } - Busted_Title_, Do not use__________.html"
526+ expect ( bad_title . title_as_filename ( '' , true ) ) . to eq "#{ note_uuid } - Busted_Title_, Do not use__________"
527+ expect ( bad_title . title_as_filename ( '.html' , true ) ) . to eq "#{ note_uuid } - Busted_Title_, Do not use__________.html"
528+ end
513529 end
514530
515531end
You can’t perform that action at this time.
0 commit comments