permit prefix to be empty in -v format string

The previous parsing of the -v vhosts made sure there were 4 tokens.
If there was no prefix specified, usage() is called.  Now, it only
checks for the firsts 3, with .prefix set to null if there are only
3 tokens.
This commit is contained in:
Josuah Demangeon 2018-04-02 02:55:00 +02:00 committed by Laslo Hunhold
parent 69bb7710eb
commit c3ddb2dd14
2 changed files with 6 additions and 4 deletions

8
main.c
View file

@ -172,9 +172,11 @@ main(int argc, char *argv[])
}
if (!(s.vhost[s.vhost_len - 1].chost = strtok(tok, " ")) ||
!(s.vhost[s.vhost_len - 1].regex = strtok(NULL, " ")) ||
!(s.vhost[s.vhost_len - 1].dir = strtok(NULL, " ")) ||
!(s.vhost[s.vhost_len - 1].prefix = strtok(NULL, " ")) ||
strtok(NULL, "")) {
!(s.vhost[s.vhost_len - 1].dir = strtok(NULL, " "))) {
usage();
}
s.vhost[s.vhost_len - 1].prefix = strtok(NULL, " ");
if (strtok(NULL, "")) {
usage();
}
break;

View file

@ -96,7 +96,7 @@ The default is "nobody".
Add the virtual host specified by
.Ar vhost ,
which has the form
.Qq Pa chost regex dir prefix ,
.Qq Pa chost regex dir [prefix] ,
where each element is separated with whitespace.
.Pp
A request matching the virtual host regular expression