Skip to content

Commit cbbea3d

Browse files
mkiedrowiczgitster
authored andcommitted
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 <[email protected]> Acked-by: Jakub Narębski <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ce61fb9 commit cbbea3d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

gitweb/gitweb.perl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,6 +1740,9 @@ sub esc_html_hl_regions {
17401740
for my $s (@sel) {
17411741
my ($begin, $end) = @$s;
17421742

1743+
# Don't create empty <span> elements.
1744+
next if $end <= $begin;
1745+
17431746
my $escaped = esc_html(substr($str, $begin, $end - $begin));
17441747

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

0 commit comments

Comments
 (0)