[PATCH v3 2/8] gitweb: esc_html_hl_regions(): Don't create empty <span> elements
- From
Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
- Date
- Apr 4, 2012, 19:57 UTC
- Message-ID
- <1333569433-3245-3-git-send-email-michal.kiedrowicz@gmail.com>
- In-Reply-To
- <1333569433-3245-1-git-send-email-michal.kiedrowicz@gmail.com>
If $end is equal to or less than $beg, 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> --- gitweb/gitweb.perl | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index a3754ff..ca3058c 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -1740,6 +1740,9 @@ sub esc_html_hl_regions { for my $s (@sel) { my ($beg, $end) = @$s; + # Don't create empty <span> elements. + next if $end <= $beg; + $out .= esc_html(substr($str, $pos, $beg - $pos)) if ($beg - $pos > 0); $out .= $cgi->span({-class => $css_class},
-- 1.7.8.4