From: Jakub Narebski <jnareb@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Jan Engelhardt <jengelh@medozas.de>,
Lea Wiemann <lewiemann@gmail.com>
Subject: Re: [PATCH] gitweb: Add charset info to "raw" blob output
Date: Sun, 1 Jun 2008 13:06:45 +0200 [thread overview]
Message-ID: <200806011306.45945.jnareb@gmail.com> (raw)
In-Reply-To: <7vprr2fi5z.fsf@gitster.siamese.dyndns.org>
On Sat, 31 May 2008, Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> Always add charset info from $default_text_plain_charset (if it is
>> defined) to "raw" (a=blob_plain) output for 'text/plain' blobs.
>> Adding charset info in a special case was removed from blob_mimetype().
>>
>> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
>> ---
>
> Looks Ok but it took a bit of digging on the list for me to figure out
> that something like this was missing from the beginning of your commit log
> message:
>
> Earlier "blob_plain" view sent "charset=utf-8" only when gitweb
> guessed the content type to be text by reading from it, and not
> when the MIME type was obtained from /etc/mime.types.
>
> This fixes the bug by always adding....
I'm sorry that I have forgot to put the "why" in commit message.
I'd add this when resending v2 of this patch.
Thanks for a comment.
> But I wonder if moving of this to the calling site is the right thing to
> do. Wouldn't it become much more contained and robust if you did it this
> way?
[...]
> sub blob_mimetype {
This _might_ be better. I didn't do this for the following two reasons:
First, from purely theoretical point of view the name of subroutine is
blob_mimetype(), and I think that charset info has place in Content-Type,
but is not part of MIME type info.
Second, blob_mimetype() is used in two places: in git_blob_plain
(in "raw" blob view) to generate correct Content-Type HTTP header, and
in git_blob to decide whether a.) blame makes sense, b.) whether to
redirect to "raw" (a=blob_plain) view. I'd rather not muck with
charset info in second case, although I don't think that it matters
at all, at least for now.
So perhaps best of those ways would be to create thin wrapper subroutine,
blob_contenttype($fd, $file_name, $mimetype), where both $file_name and
(especially) $mimetype are optional parameters, and ise it in
git_blob_plain() subroutine...
> + # Type specific postprocessing can be added as needed...
> + if ($mime =~ /^text\//i &&
> + $mime !~ /charset=/i && $default_text_plain_charset) {
> + $mime .= '; charset='.$default_text_plain_charset;
> + }
> +
> + return $mime;
I'm not sure about it. I worry a bit about text/html, which can, and
usually do, contain charset info inside the document. I'm not sure
what happens when charset information from HTTP headers contradict
charset information from presented file. That's why I have limited
adding charset info purely to 'text/plain', not 'text/*' without
charset info already present.
--
Jakub Narebski
Poland
next prev parent reply other threads:[~2008-06-01 11:07 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-28 18:04 gitweb forgets to send utf8 header for raw blob views Jan Engelhardt
2008-05-29 11:32 ` Lea Wiemann
2008-05-30 8:18 ` Jakub Narebski
2008-05-31 11:27 ` [PATCH] gitweb: Add charset info to "raw" blob output Jakub Narebski
2008-05-31 18:22 ` Junio C Hamano
2008-06-01 11:06 ` Jakub Narebski [this message]
2008-06-01 12:15 ` Jan Engelhardt
2008-06-01 12:16 ` Jan Engelhardt
2008-06-03 14:47 ` [PATCH v2] gitweb: Add charset info to "raw" output of 'text/plain' blobs Jakub Narebski
2008-05-31 15:04 ` gitweb forgets to send utf8 header for raw blob views Jan Engelhardt
2008-05-31 22:39 ` Jakub Narebski
2008-06-01 2:08 ` Jan Engelhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200806011306.45945.jnareb@gmail.com \
--to=jnareb@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jengelh@medozas.de \
--cc=lewiemann@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).