Ticket #2952 (closed defect: fixed)

Opened 11 years ago

Last modified 9 years ago

File rename handles zero-length substitutions incorrectly

Reported by: ply Owned by: andrew_b
Priority: major Milestone: 4.8.14
Component: mc-search Version: master
Keywords: Cc:
Blocked By: Blocking:
Branch state: merged Votes for changeset: committed-master

Description

  1. Problem

Suppose you want to replace a substring in some file names with another, so you do a File Rename operation with source pattern:

*OLDSTRING*

and target pattern:

\1NEWSTRING\2

If OLDSTRING occurs inside a filename, it is replaced correctly, but if at the beginning or end of the filename, the corresponding zero-length wildcard match is replaced by literal \1 or \2, respectively.

  1. Expected

Wildcards that match a zero-length substring should be substituted with an empty string.

Attachments

respect_empty_matches.patch (302 bytes) - added by boris 9 years ago.

Change History

Changed 9 years ago by boris

comment:1 follow-up: ↓ 2 Changed 9 years ago by boris

  • Component changed from mc-core to mc-search

The attached patch may fix the issue (according to GLib documentation, fnd_start and fnd_end will be both equal -1 for a zero-length match).

By the way, I wonder why mc uses its own numerous and complicated mc_search__regex_* functions instead of GLib's g_regex_replace etc.?

comment:2 in reply to: ↑ 1 Changed 9 years ago by andrew_b

  • Status changed from new to accepted
  • Owner set to andrew_b
  • Branch state changed from no branch to on review
  • Milestone changed from Future Releases to 4.8.14

Replying to boris:

The attached patch may fix the issue

Thanks! I've modified your patch and added test.

Branch: 2952_zero_length_substitution.
Initial changeset:10ac6ec85c981f0051a1877fe5d29c06d644936b

By the way, I wonder why mc uses its own numerous and complicated mc_search__regex_* functions instead of GLib's g_regex_replace etc.?

It's hard to remember after several years.

comment:3 Changed 9 years ago by slavazanko

  • Votes for changeset set to slavazanko
  • Branch state changed from on review to approved

comment:4 Changed 9 years ago by andrew_b

  • Status changed from accepted to testing
  • Votes for changeset changed from slavazanko to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

Merged to master: [3fae7c227d5b5fd71d0f4470a15516314019aa41].

git log --pretty=oneline 774762a..3fae7c2

comment:5 Changed 9 years ago by andrew_b

  • Status changed from testing to closed
Note: See TracTickets for help on using tickets.