summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-03-04 22:17:47 -0800
committerJunio C Hamano <gitster@pobox.com>2012-03-04 22:17:47 -0800
commit3ecd0c8b4d9e245e255aa4c061d6a474eb571298 (patch)
treed9ef843146787d554e3e39035c2542aca23022ba /gitweb
parent3fc242f5ab8222745892047d4e481e71540425cd (diff)
parent36612e4daf8b5b5eaf16315aa13c66925f878cd6 (diff)
downloadgit-3ecd0c8b4d9e245e255aa4c061d6a474eb571298.tar.gz
Merge branch 'jn/maint-gitweb-invalid-regexp' into maint
* jn/maint-gitweb-invalid-regexp: gitweb: Handle invalid regexp in regexp search
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.perl11
1 files changed, 10 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index d5dbd6428b..20ace61b6d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1073,7 +1073,16 @@ sub evaluate_and_validate_params {
if (length($searchtext) < 2) {
die_error(403, "At least two characters are required for search parameter");
}
- $search_regexp = $search_use_regexp ? $searchtext : quotemeta $searchtext;
+ if ($search_use_regexp) {
+ $search_regexp = $searchtext;
+ if (!eval { qr/$search_regexp/; 1; }) {
+ (my $error = $@) =~ s/ at \S+ line \d+.*\n?//;
+ die_error(400, "Invalid search regexp '$search_regexp'",
+ esc_html($error));
+ }
+ } else {
+ $search_regexp = quotemeta $searchtext;
+ }
}
}