Skip to content

Commit

Permalink
Force accurate regex match
Browse files Browse the repository at this point in the history
  • Loading branch information
jarun committed Aug 15, 2020
1 parent 7d67241 commit 5fa16db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion nnn.1
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ separated by \fI;\fR:
.Pp
\fBNNN_ARCHIVE:\fR archive extensions to be handled silently (default: bzip2, (g)zip, tar).
.Bd -literal
export NNN_ARCHIVE="(7z|bz2|gz|tar|tgz|zip)$"
export NNN_ARCHIVE="\\\\.(7z|bz2|gz|tar|tgz|zip)$"

NOTE: Non-default formats may require a third-party utility.
.Ed
Expand Down
4 changes: 1 addition & 3 deletions src/nnn.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ static const char * const patterns[] = {
"sed -i 's|^\\(\\(.*/\\)\\(.*\\)$\\)|#\\1\\n\\3|' %s",
"sed 's|^\\([^#/][^/]\\?.*\\)$|%s/\\1|;s|^#\\(/.*\\)$|\\1|' "
"%s | tr '\\n' '\\0' | xargs -0 -n2 sh -c '%s \"$0\" \"$@\" < /dev/tty'",
"(bz|bz2|gz|tar|taz|tbz|tbz2|tgz|z|zip)$",
"\\.(bz|bz2|gz|tar|taz|tbz|tbz2|tgz|z|zip)$",
"sed -i 's|^%s\\(.*\\)$|%s\\1|' %s",
};

Expand Down Expand Up @@ -5975,8 +5975,6 @@ static bool browse(char *ipath, const char *session, int pkey)

/* Get the extension for regext match */
tmp = xextension(pent->name, pent->nlen - 1);
if (tmp)
++tmp;
#ifdef PCRE
if (tmp && !pcre_exec(archive_pcre, NULL, tmp,
pent->nlen - (tmp - pent->name) - 1, 0, 0, NULL, 0)) {
Expand Down

0 comments on commit 5fa16db

Please sign in to comment.