Browse Source

gitweb: esc_html_hl_regions(): Don't create empty <span> elements

If $end is equal to or less than $begin, esc_html_hl_regions()
generates an empty <span> 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 <michal.kiedrowicz@gmail.com>
Acked-by: Jakub Narębski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Michał Kiedrowicz 13 years ago committed by Junio C Hamano
parent
commit
cbbea3dfc1
  1. 3
      gitweb/gitweb.perl

3
gitweb/gitweb.perl

@ -1740,6 +1740,9 @@ sub esc_html_hl_regions { @@ -1740,6 +1740,9 @@ sub esc_html_hl_regions {
for my $s (@sel) {
my ($begin, $end) = @$s;

# Don't create empty <span> elements.
next if $end <= $begin;

my $escaped = esc_html(substr($str, $begin, $end - $begin));

$out .= esc_html(substr($str, $pos, $begin - $pos))

Loading…
Cancel
Save