Ticket #2309 (closed defect: fixed)
"Shell patterns" broken beyond repair
Reported by: | wjaguar | Owned by: | slavazanko |
---|---|---|---|
Priority: | major | Milestone: | 4.8.14 |
Component: | mc-search | Version: | 4.7.3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Branch state: | merged | Votes for changeset: | committed-master |
Description
Function mc_search__glob_translate_to_regex() in lib/search/glob.c is horribly broken, and mishandles a number of trivial patterns such as:
- an inverted character class: "[^abc]" or "[!abc]"
- a freestanding comma: "abc,def"
- a literal brace: "{" or "}"
- an incorrectly formed brace expansion: "{abc}"
- a sequence expression: "{5..10}" or "{a..f}"
Also, a nested brace expansion: "a{b,c{d,e}}f" will produce capturing parentheses for every pair of braces, instead of only the outermost pair.
All this because current code is far too simple-minded to correctly convert Bash patterns into PCRE regexes, and needs a complete rewrite.
Attachments
Change History
comment:1 Changed 13 years ago by andrew_b
- Branch state set to no branch
- Milestone changed from 4.7 to Future Releases
comment:2 Changed 10 years ago by boris
Please, look at the proposed patch. It does not intend to fix all Bash patterns (I believe mc never claimed to support all kinds of them), but it fixes some issues.
Namely, backslash-escaped metacharacter like {}*? will remain in the pattern (with the current code it is just stripped). Second, comma will be transformed to | only inside a group.
comment:5 Changed 10 years ago by slavazanko
- Status changed from new to accepted
- Owner set to slavazanko
comment:6 Changed 10 years ago by slavazanko
- Branch state changed from no branch to on review
Created branch 2309_shell_patterns
Initial changeset:0eca32a852593c9bda46b48a8547af7d306b60b2
Review please.
comment:7 Changed 10 years ago by andrew_b
- Votes for changeset set to andrew_b
- Branch state changed from on review to approved
- Milestone changed from Future Releases to 4.8.14
Approved with simple fixup.
comment:8 Changed 10 years ago by slavazanko
- Status changed from accepted to testing
- Votes for changeset changed from andrew_b to committed-master
- Resolution set to fixed
- Blocking 2577, 3350 removed
- Branch state changed from approved to merged
Merged to master:
git log --pretty=oneline f4faf60..6ca737d
comment:10 Changed 8 years ago by mooffie
Ticket #2577 has been marked as a duplicate of this ticket.