From cbbea3dfc1a1cfe382e58488c389471b4ab21876 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Micha=C5=82=20Kiedrowicz?= Date: Wed, 11 Apr 2012 23:18:38 +0200 Subject: [PATCH] gitweb: esc_html_hl_regions(): Don't create empty elements MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit If $end is equal to or less than $begin, esc_html_hl_regions() generates an empty element. It normally shouldn't be visible in the web browser, but it doesn't look good when looking at page source. It also minimally increases generated page size for no special reason. Signed-off-by: Michał Kiedrowicz Acked-by: Jakub Narębski Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 1c5430158..588b87d23 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1740,6 +1740,9 @@ sub esc_html_hl_regions { for my $s (@sel) { my ($begin, $end) = @$s; + # Don't create empty elements. + next if $end <= $begin; + my $escaped = esc_html(substr($str, $begin, $end - $begin)); $out .= esc_html(substr($str, $pos, $begin - $pos)) -- 2.26.2