Subject: Re: [PATCH (BUGFIX)] gitweb: Handle invalid regexp in regexp search

From: Ramsay Jones <[email-masked]>
Date: Fri, 02 Mar 2012 19:44:39 +0000

Jakub Narebski wrote:
> When using regexp search ('sr' parameter / $search_use_regexp variable
> is true), check first that regexp is valid.
> 
> Without this patch we would get an error from Perl during search (if
> searching is performed by gitweb), or highlighting matches substring
> (if applicable), if user provided invalid regexp... which means broken
> HTML, with error page (including HTTP headers) generated after gitweb
> already produced some output.
> 
> Add test that illustrates such error: for example for regexp "*\.git"
> we would get the following error:
> 
>   Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE \.git/
>   at /var/www/cgi-bin/gitweb.cgi line 3084.
> 
> Reported-by: Ramsay Jones <[email-masked]>
> Signed-off-by: Jakub Narebski <[email-masked]>
> ---
> See "Re: gitweb: (potential) problems with new installation"
> http://thread.gmane.org/gmane.comp.version-control.git/191746

This patch solves the problem for me when using a regex search
(re checkbox checked), but *not* for a non-regex search.

If you have a leading '*' or '+', in the non-regex case, then you
still get the above complaint (and xml error page etc.), although
the line number has changed slightly from that given above.

ATB,
Ramsay Jones