httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guenter Knauf <fua...@apache.org>
Subject Re: svn commit: r1466669 - /httpd/httpd/branches/2.4.x/STATUS
Date Fri, 12 Apr 2013 20:42:08 GMT
On 10.04.2013 23:21, Guenter Knauf wrote:
> On 10.04.2013 23:01, fuankg@apache.org wrote:
>> Author: fuankg
>> Date: Wed Apr 10 21:01:51 2013
>> New Revision: 1466669
>>
>> URL: http://svn.apache.org/r1466669
>> Log:
>> Put this backport for now on hold to get some more
>> time for testing ...

> ok, onward with some more testing .....
now on r:regex() ...

1) the sample in the docs is completely wrong ...
1.1) the docu has r:regex(string, pattern) but current code implements 
r:regex(pattern, string); I will change this in the code soon since I it 
looks more Lua-like for me what is in the docs since all other Lua match 
functions also have parameters in the order (string, pattern)
1.2) the pattern "foo (%w+) (%S*)" doesnt work for me; it looks more 
like a pattern for string.match(); instead a valid pattern for r:regex() 
would be f.e. "foo (\\w+) (\\a+)"; backslash must be escaped in a Lua string

2) r:regex() crashes the server if more than AP_MAX_REG_MATCH matches 
are found; this is because we still get the real number of matches in 
regex.re_nsub although passing in AP_MAX_REG_MATCH:
     rv = ap_regexec(&regex, source, AP_MAX_REG_MATCH, matches, 0);

when I add:

     if (regex.re_nsub > AP_MAX_REG_MATCH) {
         ap_log_rerror(APLOG_MARK, APLOG_INFO, 0, r,
                       "regex returned %d matches; allowed %d.",
                       regex.re_nsub, AP_MAX_REG_MATCH);
         return 2;
     }

and test with a 20 match regex, I get this in the log:
regex returned 20 matches; allowed 10.

The docu of regexec() gives no hints about how to retrieve the real 
number of matches stored:
http://ci.apache.org/projects/httpd/trunk/doxygen/ap__regex_8h.html
and I've not yet digged into the code; but we need to make sure that the 
following loop doesnt loop over AP_MAX_REG_MATCH:
     for (i = 0; i <= regex.re_nsub; i++) {

BTW. what is the reason for limiting AP_MAX_REG_MATCH to 10 in httpd.h ?

Gün.



Mime
View raw message