Skip to contentSkip to conversation

gitweb: Do not use esc_html in esc_path

PATCH In review Jakub Narebski 2 participants 3 messages Aug 11, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitweb: Do not use esc_html in esc_path

Do not use esc_html in esc_path subroutine to avoid double quoting; expand esc_html body (except quoting) in esc_path.

Move esc_path before quot_cec and quot_upr. Add some comments.

---
This patch was send to git mailing list; I don't know if it was missed, or rejected.

 gitweb/gitweb.perl |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)
gitweb/gitweb.perl +17 -11
index ce185d9..53214b0 100755
@@ -585,7 +585,21 @@ sub esc_html ($;%) {
 	return $str;
 }
 
-# Make control characterss "printable".
+# quote control characters and escape filename to HTML
+sub esc_path {
+	my $str = shift;
+	my %opts = @_;
+
+	$str = to_utf8($str);
+	$str = escapeHTML($str);
+	if ($opts{'-nbsp'}) {
+		$str =~ s/ / /g;
+	}
+	$str =~ s|([[:cntrl:]])|quot_cec($1)|eg;
+	return $str;
+}
+
+# Make control characters "printable", using character escape codes (CEC)
 sub quot_cec {
 	my $cntrl = shift;
 	my %es = ( # character escape codes, aka escape sequences
@@ -605,22 +619,14 @@ sub quot_cec {
 	return "<span class=\"cntrl\">$chr</span>";
 }
 
-# Alternatively use unicode control pictures codepoints.
+# Alternatively use unicode control pictures codepoints,
+# Unicode "printable representation" (PR)
 sub quot_upr {
 	my $cntrl = shift;
 	my $chr = sprintf('&#%04d;', 0x2400+ord($cntrl));
 	return "<span class=\"cntrl\">$chr</span>";
 }
 
-# quote control characters and escape filename to HTML
-sub esc_path {
-	my $str = shift;
-
-	$str = esc_html($str);
-	$str =~ s|([[:cntrl:]])|quot_cec($1)|eg;
-	return $str;
-}
-
 # git may return quoted and escaped filenames
 sub unquote {
 	my $str = shift;
Signature · 1 line
1.4.3.4
#1 lore raw
Quoted 9 lines · Jakub Narebski

Do not use esc_html in esc_path subroutine to avoid double quoting; expand esc_html body (except quoting) in esc_path.

Move esc_path before quot_cec and quot_upr. Add some comments.

---
This patch was send to git mailing list; I don't know if it was missed, or rejected.

I do not remember looking at it deeply, so probably it was just lost in the noise.

Unless there was a list discussion that was unfavorable, that is; but I do not recall one and the patch looks sane.

#2 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 3 lines · Jakub Narebski

---
This patch was send to git mailing list; I don't know if it was missed, or rejected.

I do not remember looking at it deeply, so probably it was just lost in the noise.

Unless there was a list discussion that was unfavorable, that is; but I do not recall one and the patch looks sane.

There was no discussion, so probably the patch was just lost in the noise. It happens.

Signature · 1 line
Jakub Narebski