[PATCH v4 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 $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@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 1c54301..588b87d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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))
-- 
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]