git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Do not use esc_html in esc_path
@ 2006-11-25  8:43 Jakub Narebski
  2006-11-25  9:45 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2006-11-25  8:43 UTC (permalink / raw)
  To: git; +Cc: 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.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
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(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ce185d9..53214b0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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/ /&nbsp;/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;
-- 
1.4.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] gitweb: Do not use esc_html in esc_path
@ 2006-11-21 20:43 Jakub Narebski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Narebski @ 2006-11-21 20:43 UTC (permalink / raw)
  To: git; +Cc: 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.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index ce185d9..53214b0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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/ /&nbsp;/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;
-- 
1.4.3.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2006-11-25  9:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-25  8:43 [PATCH] gitweb: Do not use esc_html in esc_path Jakub Narebski
2006-11-25  9:45 ` Junio C Hamano
2006-11-25  9:54   ` Jakub Narebski
  -- strict thread matches above, loose matches on Subject: below --
2006-11-21 20:43 Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).