]> Lady’s Gitweb - Gitweb/commit
gitweb: Handle invalid regexp in regexp search
authorJakub Narebski <redacted>
Tue, 28 Feb 2012 18:41:47 +0000 (19:41 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:32 +0000 (00:51 -0400)
commit7f7b9389478c8990ccd0a52bfe74e5dca2d2137c378c4f27ec43aaed3a06e98a
treeaa287d6e30fd612c75a17e909383633b4f9feaba0c6e25962ba634848aa4a293
parentc77ad442fb79805bda442e469e4b03ab7272d4ca201b2ccd025be3f57a20d2e5
gitweb: Handle invalid regexp in regexp search

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 <redacted>
Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl
This page took 0.228431 seconds and 5 git commands to generate.