From: Michał Kiedrowicz Date: Wed, 11 Apr 2012 21:18:38 +0000 (+0200) Subject: gitweb: esc_html_hl_regions(): Don't create empty elements X-Git-Tag: v1.7.11-rc0~107^2~6 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=cbbea3dfc1a1cfe382e58488c389471b4ab21876;p=git.git gitweb: esc_html_hl_regions(): Don't create empty elements 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 --- 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))