httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ewald Dieterich <ewald_dieter...@t-online.de>
Subject mod_proxy: ProxyPass, Location and regex check
Date Mon, 03 Mar 2014 12:45:11 GMT
I try to get

1  <Location "/?*[]/">
2      ProxyPass "http://backend/?*[]/"
3      ProxyPassReverse "http://backend/?*[]/"
4  </Location>

to work and get the error message

AH00526: Syntax error on line 2 of ...:
Regular expression could not be compiled.

I guess that "/?*[]/" is a valid location, right? So it should work, I 
guess.

In mod_proxy.c, add_pass(), there is this snippet to detect a regex in 
the location (f is cmd->path, which is the location):

if (cmd->path) {
     [...]
     if (apr_fnmatch_test(f)) {
         use_regex = 1;
     }
}

And later:

if (use_regex) {
     new->regex = ap_pregcomp(cmd->pool, f, AP_REG_EXTENDED);
     if (new->regex == NULL)
         return "Regular expression could not be compiled.";
     [...]
}

I think the reason for this is to handle a regex in a location correctly 
(either <LocationMatch ...> or <Location ~ ...>).

Why is apr_fnmatch_test() used to recognize a regex? It only checks for 
*, ? and [] pairs (the comment of apr_fnmatch_test() is misleading: 
"Determine if the given pattern is a regular expression.").

Is there a better way to check the location for a regex? I don't think 
so because I can configure a valid non-regex location that looks exactly 
like a regex. Maybe expand struct cmd_parms_struct by a flag that marks 
path as a regex? Then you wouldn't have to guess.

Thoughts? Maybe I'm understanding something wrong?

Mime
View raw message