git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH (lite)] gitweb: Sanitize title attribute in format_subject_html

From
Jakub Narebski <jnareb@gmail.com>
Date
May 22, 2009, 15:39 UTC
Message-ID
<200905221739.35254.jnareb@gmail.com>
In-Reply-To
<200905221735.48310.jnareb@gmail.com>

Replace control characters with question mark '?' (like in chop_and_esc_str).

While at it: chop_and_escape_str doesn't need capturing group.
Noticed-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This version has more sane ratio of commit message length to actual
change...
 gitweb/gitweb.perl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 05702e4..1e7e2d8 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1236,7 +1236,7 @@ sub chop_and_escape_str {
 	if ($chopped eq $str) {
 		return esc_html($chopped);
 	} else {
-		$str =~ s/([[:cntrl:]])/?/g;
+		$str =~ s/[[:cntrl:]]/?/g;
 		return $cgi->span({-title=>$str}, esc_html($chopped));
 	}
 }
@@ -1459,6 +1459,7 @@ sub format_subject_html {
 	$extra = '' unless defined($extra);
 
 	if (length($short) < length($long)) {
+		$long =~ s/[[:cntrl:]]/?/g;
 		return $cgi->a({-href => $href, -class => "list subject",
 		                -title => to_utf8($long)},
 		       esc_html($short) . $extra);
-- 
1.6.3.1
Previous: Jakub NarebskiNext: Jakub Narebski
Message 2 of 3 in “gitweb: Sanitize title attribute in format_subject_html”
  1. gitweb: Sanitize title attribute in format_subject_htmlJakub Narebski, May 22, 2009
  2. gitweb: Sanitize title attribute in format_subject_htmlJakub Narebski, May 22, 2009
  3. gitweb: Introduce and use esc_attr to escape values of tag attributesJakub Narebski, May 22, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.