Re: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Graham Leggett

On 19 May 2011, at 1:06 PM, Yehezkel Horowitz wrote:

Can anyone explain why ap_regexec can take only NULL terminated  
string?


I’m working in filter context and want to run regular expression on  
bucket content (so I have the buffer length).


Currently I had to copy the bucket content and add the NULL at the  
end before passing it to ap_regexec (this is a waste of CPU and  
memory).


The underling PCRE engine support getting the length of the input  
string (actually ap_regexec just run strlen on the string and pass  
the result to pcre_exec)


Can you consider adding API for this? (Of course it will get the  
input length as argument)


Similar request (from 2002) could be found at http://www.mail-archive.com/dev@httpd.apache.org/msg12986.html 
 but without any reply.


Sounds like a sensible thing to have.

Is there a patch for this anywhere that we can take a look at, or is  
this just a suggestion at this point?


Regards,
Graham
--



RE: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Yehezkel Horowitz
I have a patch (based on 2.2.17) to where should I submit it?


From: Graham Leggett [mailto:minf...@sharp.fm]
Sent: Thursday, May 19, 2011 2:23 PM
To: dev@httpd.apache.org
Cc: Anatoli Tubman; Ethan Schorer
Subject: Re: ap_regexec API for buffers (not NULL terminated strings)

On 19 May 2011, at 1:06 PM, Yehezkel Horowitz wrote:

Can anyone explain why ap_regexec can take only NULL terminated string?

I'm working in filter context and want to run regular expression on bucket 
content (so I have the buffer length).

Currently I had to copy the bucket content and add the NULL at the end before 
passing it to ap_regexec (this is a waste of CPU and memory).

The underling PCRE engine support getting the length of the input string 
(actually ap_regexec just run strlen on the string and pass the result to 
pcre_exec)

Can you consider adding API for this? (Of course it will get the input length 
as argument)

Similar request (from 2002) could be found at 
http://www.mail-archive.com/dev@httpd.apache.org/msg12986.html but without any 
reply.

Sounds like a sensible thing to have.

Is there a patch for this anywhere that we can take a look at, or is this just 
a suggestion at this point?

Regards,
Graham
--



Scanned by Check Point Total Security Gateway.


Re: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Graham Leggett

On 19 May 2011, at 1:24 PM, Yehezkel Horowitz wrote:


I have a patch (based on 2.2.17) to where should I submit it?


Add it to bugzilla so it doesn't get lost, and then ping here, so  
someone can pick it up.


Ideally, the patch should apply to httpd-trunk first, but having a  
v2.2 patch also (assuming the trunk one doesn't apply as is) makes it  
easier to propose for backport.


Regards,
Graham
--



RE: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Yehezkel Horowitz
Hi Graham

I have opened record #51231 in bugzilla (patch attached to the record).
https://issues.apache.org/bugzilla/show_bug.cgi?id=51231

Thanks

Yehezkel


From: Graham Leggett [mailto:minf...@sharp.fm]
Sent: Thursday, May 19, 2011 2:33 PM
To: dev@httpd.apache.org
Subject: Re: ap_regexec API for buffers (not NULL terminated strings)

On 19 May 2011, at 1:24 PM, Yehezkel Horowitz wrote:


I have a patch (based on 2.2.17) to where should I submit it?

Add it to bugzilla so it doesn't get lost, and then ping here, so someone can 
pick it up.

Ideally, the patch should apply to httpd-trunk first, but having a v2.2 patch 
also (assuming the trunk one doesn't apply as is) makes it easier to propose 
for backport.

Regards,
Graham
--



Re: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Nick Kew

On 19 May 2011, at 12:22, Graham Leggett wrote:

 On 19 May 2011, at 1:06 PM, Yehezkel Horowitz wrote:
 
 Can anyone explain why ap_regexec can take only NULL terminated string?

Presumably because that's what PCRE supports!

 Sounds like a sensible thing to have.

Indeed, I could certainly use it.  But surely this should be an enhancement
request for PCRE.  Once they have it, wrapping the API for HTTPD
becomes trivial!

Anyone sufficiently familiar with regexp internals to say what it would take?

-- 
Nick Kew

Available for work, contract or permanent
http://www.webthing.com/~nick/cv.html



RE: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Yehezkel Horowitz
Hi Nick

As I mentioned in my original mail, PCRE DO support getting the length as 
argument!

Please take a short look at ap_regexec implementation (util_pcre.c file) and 
you will see that current code pass PCRE the length (which is obtained with 
strlen).

So it is just change in HTTPD wrapping API!

Best regards, 

Yehezkel

-Original Message-
From: Nick Kew [mailto:n...@webthing.com] 
Sent: Thursday, May 19, 2011 5:27 PM
To: dev@httpd.apache.org
Subject: Re: ap_regexec API for buffers (not NULL terminated strings)


On 19 May 2011, at 12:22, Graham Leggett wrote:

 On 19 May 2011, at 1:06 PM, Yehezkel Horowitz wrote:
 
 Can anyone explain why ap_regexec can take only NULL terminated string?

Presumably because that's what PCRE supports!

 Sounds like a sensible thing to have.

Indeed, I could certainly use it.  But surely this should be an enhancement
request for PCRE.  Once they have it, wrapping the API for HTTPD
becomes trivial!

Anyone sufficiently familiar with regexp internals to say what it would take?

-- 
Nick Kew

Available for work, contract or permanent
http://www.webthing.com/~nick/cv.html


Scanned by Check Point Total Security Gateway.


Re: ap_regexec API for buffers (not NULL terminated strings)

2011-05-19 Thread Nick Kew

On 19 May 2011, at 15:27, Nick Kew wrote:

 Presumably because that's what PCRE supports!

Aaargh!  Ignore that.  Saw your post and read it as regcomp.

The suggestion is totally sensible as well as trivial.  Thank you.

-- 
Nick Kew

Available for work, contract or permanent
http://www.webthing.com/~nick/cv.html