[PATCH v3 2/8] gitweb: esc_html_hl_regions(): Don't create empty <span> elements

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Acked-by: Jakub Narębski <jnareb@xxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]