]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: esc_html_hl_regions(): Don't create empty <span> elements
authorMichał Kiedrowicz <redacted>
Wed, 11 Apr 2012 21:18:38 +0000 (23:18 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:32 +0000 (00:51 -0400)
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 <redacted>
Acked-by: Jakub Narębski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index e8f277c35014e650251461b9e1706750a37afdc0bb6a33f370c09531d1387518..91663a4d044681f218a5bbbbff8eba71f6ce3abbc408a4cfef6f7291d72c55da 100755 (executable)
@@ -1741,6 +1741,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))
This page took 0.385593 seconds and 4 git commands to generate.