summaryrefslogtreecommitdiff
path: root/gitweb/gitweb.perl
diff options
context:
space:
mode:
authorMichał Kiedrowicz <michal.kiedrowicz@gmail.com>2012-04-11 21:18:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-04-11 21:26:01 (GMT)
commitcbbea3dfc1a1cfe382e58488c389471b4ab21876 (patch)
tree04c43a3a2606fad78f9f26423a9a4a19117d9a48 /gitweb/gitweb.perl
parentce61fb968f9b86f5d889eeb7b80da8ec3d6bfb9b (diff)
downloadgit-cbbea3dfc1a1cfe382e58488c389471b4ab21876.zip
git-cbbea3dfc1a1cfe382e58488c389471b4ab21876.tar.gz
git-cbbea3dfc1a1cfe382e58488c389471b4ab21876.tar.bz2
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 <michal.kiedrowicz@gmail.com> Acked-by: Jakub Narębski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb/gitweb.perl')
-rwxr-xr-xgitweb/gitweb.perl3
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))