File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,11 @@ impl AllowListLine {
140140
141141#[ allow( clippy:: single_char_pattern) ]
142142fn glob_to_regex ( expr : & str ) -> Result < Regex > {
143+ // Treat `.` as literal, not match-any.
144+ //
145+ // Use character class syntax to avoid double-escaping.
146+ let expr = expr. replace ( "." , r"[.]" ) ;
147+
143148 // Don't make users escape Windows path separators.
144149 let expr = expr. replace ( r"\" , r"\\" ) ;
145150
Original file line number Diff line number Diff line change 1+ a.*
Original file line number Diff line number Diff line change @@ -99,3 +99,20 @@ fn test_allow_glob_except_commented() -> Result<()> {
9999
100100 Ok ( ( ) )
101101}
102+
103+ #[ test]
104+ fn test_allow_glob_extension ( ) -> Result < ( ) > {
105+ let text = include_str ! ( "test-data/allow-all-glob-extension.txt" ) ;
106+ let allowlist = AllowList :: parse ( text) ?;
107+
108+ assert ! ( allowlist. is_allowed( "a.c" ) ) ;
109+ assert ! ( allowlist. is_allowed( "a.h" ) ) ;
110+
111+ assert ! ( !allowlist. is_allowed( "ac" ) ) ;
112+ assert ! ( !allowlist. is_allowed( "ah" ) ) ;
113+
114+ assert ! ( !allowlist. is_allowed( "axc" ) ) ;
115+ assert ! ( !allowlist. is_allowed( "axh" ) ) ;
116+
117+ Ok ( ( ) )
118+ }
You can’t perform that action at this time.
0 commit comments