File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -594,3 +594,18 @@ fn tr_arguments_validation_error_message_format() {
594
594
"tr: missing operand after ‘a’. Two strings must be given when translating.\n " ,
595
595
) ;
596
596
}
597
+
598
+ // POSIX does not specify how invalid backslash sequences are handled, so there is some flexibility here
599
+ // Still, something useful should be done (for instance, tr should not abort in this case)
600
+ #[ test]
601
+ fn tr_ranges_with_invalid_escape_sequences ( ) {
602
+ const INPUT : & str = "abcdef ABCDEF -\\ \x07 -\\ 123456789" ;
603
+
604
+ // "\7-\9" is:
605
+ // treated as a range from \007 through '9' by bsdutils and GNU Core Utilities
606
+ // treated as: 1) a range from \007 through '\', and 2) separately the character '9', by BusyBox
607
+ tr_test ( & [ "-d" , r"\7-\9" ] , INPUT , r"abcdefABCDEF\\" ) ;
608
+
609
+ // Similar to above
610
+ tr_test ( & [ "-d" , r"\7-\A" ] , INPUT , r"abcdefBCDEF\\" ) ;
611
+ }
You can’t perform that action at this time.
0 commit comments