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

[PATCH] gitweb: text files for 'blob_plain' action without charset by default

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 17, 2006, 16:07 UTC
Message-ID
<e719bi$vfd$1@sea.gmane.org>
In-Reply-To
<20060617153540.GI2609@pasky.or.cz>

$default_text_plain_charset is undefined (no specified charset) by default. Additionally ':raw' layer for binmode is used for outputting file content.

---
This patch depends on the previous patch in the thread:
  "gitweb: safely output binary files for 'blob_plain' action"
Contrary to the previous patch it is not based on other unrelated gitweb.cgi
patches (this changes only line numbers in patch).
 gitweb/gitweb.cgi |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
53209981db06a5dde7c59caada279bf63d329da8
diff --git a/gitweb/gitweb.cgi b/gitweb/gitweb.cgi
index acac1f4..f082e5d 100755
--- a/gitweb/gitweb.cgi
+++ b/gitweb/gitweb.cgi
@@ -44,7 +44,7 @@ my $projects_list =   "index/index.aux";
 
 # default blob_plain mimetype and default charset for text/plain blob
 my $default_blob_plain_mimetype = 'text/plain';
-my $default_text_plain_charset  = 'utf-8';     # can be undefined
+my $default_text_plain_charset  = undef;       # was: 'utf-8'
 
 # input validation and dispatch
 my $action = $cgi->param('a');
@@ -1451,9 +1451,9 @@ sub git_blob_plain {
 
        print $cgi->header(-type => "$type", '-content-disposition' => "inline; filename=\"$save_as\"");
        undef $/;
-       binmode STDOUT, ':raw' unless $type =~ m/^text\//;
+       binmode STDOUT, ':raw';
        print <$fd>;
-       binmode STDOUT, ':utf8' unless $type =~ m/^text\//;
+       binmode STDOUT, ':utf8'; # as set at the beginning of gitweb.cgi
        $/ = "\n";
        close $fd;
 }
-- 
1.3.0
Previous: Petr BaudisNext: Junio C Hamano
Message 3 of 6 in “gitweb: safely output binary files for 'blob_plain' action”
  1. gitweb: safely output binary files for 'blob_plain' actionJakub Narebski, Jun 17, 2006
  2. Petr BaudisJun 17, 2006
  3. gitweb: text files for 'blob_plain' action without charset by defaultJakub Narebski, Jun 17, 2006
  4. Junio C HamanoJun 17, 2006
  5. Petr BaudisJun 17, 2006
  6. Junio C HamanoJun 17, 2006

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.