Skip to content

Commit

Permalink
Fix bug using LESSOPEN with filenames containing shell metachars.
Browse files Browse the repository at this point in the history
  • Loading branch information
gwsw committed Jul 29, 2017
1 parent 0734f75 commit 918c307
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ AH_TOP([
/*
* Default shell metacharacters and meta-escape character.
*/
#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~"
#define DEF_METACHARS "; *?\t\n'\"()<>[]|&^`#\\$%=~{},"
#define DEF_METAESCAPE "\\"
/*
Expand Down
7 changes: 5 additions & 2 deletions filename.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ open_altfile(filename, pf, pfd)
return (NULL);
#else
char *lessopen;
char *qfilename;
char *cmd;
int len;
FILE *fd;
Expand Down Expand Up @@ -874,9 +875,11 @@ open_altfile(filename, pf, pfd)
return (NULL);
}

len = (int) (strlen(lessopen) + strlen(filename) + 2);
qfilename = shell_quote(filename);
len = (int) (strlen(lessopen) + strlen(qfilename) + 2);
cmd = (char *) ecalloc(len, sizeof(char));
SNPRINTF1(cmd, len, lessopen, filename);
SNPRINTF1(cmd, len, lessopen, qfilename);
free(qfilename);
fd = shellcmd(cmd);
free(cmd);
if (fd == NULL)
Expand Down
3 changes: 2 additions & 1 deletion version.c
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ v512 7/26/17 Fix MSDOS build.
v513 7/26/17 Fix switch to normal attr at end of line with -R and rscroll.
v514 7/27/17 Fix bug in fcomplete when pattern does not match a file.
v515 7/28/17 Allow 'u' in -D option on Windows.
v516 7/29/17 Fix bug using LESSOPEN with filename containing metachars.
*/

char version[] = "515";
char version[] = "516";

0 comments on commit 918c307

Please sign in to comment.