Re: reqrep always replaces, even when position \x is not found?

From: Willy Tarreau <w#1wt.eu>
Date: Wed, 26 Aug 2009 09:38:23 +0200


Hi,

On Mon, Aug 24, 2009 at 12:10:41PM +0100, Pedro Mata-Mouros Fonseca wrote:
> Greetings,
>
> Sorry for the "double" posting, let me just try to simplify the
> exposition of the problem. I'm trying to rewrite a URI using regular
> expression placeholders, but I'm having a problem that when a
> placeholder doesn't match anything it still gets replaced in the
> destination with a '1'. This is the configuration directive (basically
> if the URI is rss2, rewrite to RSS2; but if it is rss only, rewrite to
> RSS):
>
> reqrep ^([^\ ]*)\ /rss(2*)(.*) \1\ /Endpoint/RSS\2\3
>
> Calling rss2 correctly rewrites the URI:
> => /rss2?u=username correctly rewrites to /Endpoint/RSS2?u=username
>
> However calling rss (without the '2') triggers a wrong replacement:
> => /rss?u=username incorrectly rewrites to /Endpoint/RSS1?u=username,
> instead of /Endpoint/RSS?u=username
>
> This is the content of the log:
> 10.134.15.124 - - [21/Aug/2009:12:08:33 +0100] "GET /Endpoint/RSS2?
> u=username HTTP/1.1" 404 209
> 10.134.15.124 - - [21/Aug/2009:12:09:05 +0100] "GET /Endpoint/RSS1?
> u=username HTTP/1.1" 404 209
>
> Many thanks again.

For me it works well :
  GET /Endpoint/RSS?u=username HTTP/1.0

So it looks like a bug in the regex lib. My version was built with PCRE and with glibc's standard regex library. What OS/regex lib are you using ? A lot of those libs are buggy, and before I discovered PCRE, I had tried several alternatives with pretty unfortunate experiences !

Regards,
Willy Received on 2009/08/26 09:38

This archive was generated by hypermail 2.2.0 : 2009/08/26 09:45 CEST