From: Michał Kiedrowicz Date: Wed, 11 Apr 2012 21:18:38 GMT Subject: [PATCH v4 2/8] gitweb: esc_html_hl_regions(): Don't create empty elements Message-ID: <1334179124-14258-3-git-send-email-michal.kiedrowicz@gmail.com> In-Reply-To: <1334179124-14258-1-git-send-email-michal.kiedrowicz@gmail.com> If $end is equal to or less than $begin, esc_html_hl_regions() generates an empty 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 Acked-by: Jakub Narębski --- 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 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