Ticket #2309 (closed defect: fixed)

Opened 14 years ago

Last modified 8 years ago

"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

glob-to-regex.patch (1.7 KB) - added by boris 10 years ago.

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

Changed 10 years ago by boris

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:3 Changed 10 years ago by andrew_b

  • Blocking 3350 added

comment:4 Changed 10 years ago by andrew_b

  • Blocking 2577 added

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 [e5ec837b98663921f44349369f1a38ec8bbd50fe]:

git log --pretty=oneline f4faf60..6ca737d
Last edited 10 years ago by andrew_b (previous) (diff)

comment:9 Changed 10 years ago by slavazanko

  • Status changed from testing to closed

comment:10 Changed 8 years ago by mooffie

Ticket #2577 has been marked as a duplicate of this ticket.

Note: See TracTickets for help on using tickets.