File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -3109,17 +3109,30 @@ impl Hash for Path {
3109
3109
bytes_hashed += to_hash. len ( ) ;
3110
3110
}
3111
3111
3112
- // skip over separator and optionally a following CurDir item
3112
+ // Skip over separators and, optionally, a following CurDir item
3113
3113
// since components() would normalize these away.
3114
3114
component_start = i + 1 ;
3115
3115
3116
3116
let tail = & bytes[ component_start..] ;
3117
3117
3118
3118
if !verbatim {
3119
3119
component_start += match tail {
3120
+ // At the end of the path, e.g. `foo/`
3121
+ [ ] => 0 ,
3122
+ // At the end of the path followed by a CurDir component, e.g. `foo/.`
3120
3123
[ b'.' ] => 1 ,
3124
+ // Followed by a CurDir component, another separator, and a component e.g. `foo/./bar`
3121
3125
[ b'.' , sep @ _, ..] if is_sep_byte ( * sep) => 1 ,
3122
- _ => 0 ,
3126
+ // Followed by another separator and a component, e.g. `foo//bar`
3127
+ [ sep @ _, ..] if is_sep_byte ( * sep) => 1 ,
3128
+ // Otherwise, it's a separator followed by a new component, e.g. `foo/bar`
3129
+ // and we should hash the separator to distinguish from `foobar`
3130
+ _ => {
3131
+ let to_hash = & [ b'/' as u8 ] ;
3132
+ h. write ( to_hash) ;
3133
+ bytes_hashed += to_hash. len ( ) ;
3134
+ 0
3135
+ }
3123
3136
} ;
3124
3137
}
3125
3138
}
You can’t perform that action at this time.
0 commit comments