]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: esc_html_hl_regions(): Don't create empty <span> elements
[Gitweb] / gitweb.perl
index 351f524ee1fdde0391450146bf8fff3babceaaf5e9604e0e041267a21d98b021..91663a4d044681f218a5bbbbff8eba71f6ce3abbc408a4cfef6f7291d72c55da 100755 (executable)
@@ -1739,12 +1739,18 @@ sub esc_html_hl_regions {
        my $pos = 0;
 
        for my $s (@sel) {
-               $out .= esc_html(substr($str, $pos, $s->[0] - $pos))
-                       if ($s->[0] - $pos > 0);
-               $out .= $cgi->span({-class => $css_class},
-                                  esc_html(substr($str, $s->[0], $s->[1] - $s->[0])));
+               my ($begin, $end) = @$s;
 
-               $pos = $s->[1];
+               # 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))
+                       if ($begin - $pos > 0);
+               $out .= $cgi->span({-class => $css_class}, $escaped);
+
+               $pos = $end;
        }
        $out .= esc_html(substr($str, $pos))
                if ($pos < length($str));
@@ -3887,6 +3893,7 @@ sub print_feed_meta {
                                '-type' => "application/$type+xml"
                        );
 
+                       $href_params{'extra_options'} = undef;
                        $href_params{'action'} = $type;
                        $link_attr{'-href'} = href(%href_params);
                        print "<link ".
This page took 0.267897 seconds and 4 git commands to generate.