diff --git a/doc/configuration.txt b/doc/configuration.txt index 1ca54fe80..93914a570 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -5893,8 +5893,15 @@ The following ACL flags are currently supported : The "-f" flag is special as it loads all of the lines it finds in the file specified in argument and loads all of them before continuing. It is even possible to pass multiple "-f" arguments if the patterns are to be loaded from -multiple files. Also, note that the "-i" flag applies to subsequent entries and -not to entries loaded from files preceeding it. For instance : +multiple files. Empty lines as well as lines beginning with a sharp ('#') will +be ignored. All leading spaces and tabs will be stripped. If it is absolutely +needed to insert a valid pattern beginning with a sharp, just prefix it with a +space so that it is not taken for a comment. Depending on the data type and +match method, haproxy may load the lines into a binary tree, allowing very fast +lookups. This is true for IPv4 and exact string matching. In this case, +duplicates will automatically be removed. Also, note that the "-i" flag applies +to subsequent entries and not to entries loaded from files preceeding it. For +instance : acl valid-ua hdr(user-agent) -f exact-ua.lst -i -f generic-ua.lst test diff --git a/src/acl.c b/src/acl.c index f548c1756..adf44941c 100644 --- a/src/acl.c +++ b/src/acl.c @@ -770,11 +770,24 @@ static int acl_read_patterns_from_file( struct acl_keyword *aclkw, */ opaque = 0; pattern = NULL; - args[0] = trash; args[1] = ""; while (fgets(trash, sizeof(trash), file) != NULL) { c = trash; + + /* ignore lines beginning with a dash */ + if (*c == '#') + continue; + + /* strip leading spaces and tabs */ + while (*c == ' ' || *c == '\t') + c++; + + /* empty lines are ignored too */ + if (!*c) + continue; + + args[0] = c; while (*c && *c != '\n' && *c != '\r') c++; *c = 0;