You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Greg Lindahl <li...@pbm.com> on 2007/05/09 06:12:53 UTC

[users@httpd] utf8 charset question

I have some webpages and a CGI script which are utf8. This is apache2 on Linux.

With this .htaccess file:

AddHandler cgi-script cgi
#AddDefaultCharset UTF-8
#AddCharset utf-8 .cgi .html
#AddType "text/html; charset=UTF-8" .cgi .html
Options +ExecCGI

With all 3 lines commented, both the webpages and the CGI emit
iso-8859-1, my server default.

If I uncomment any one of the 3 commented lines. my .html pages all
come out utf-8. But, no matter what, my cgi always is iso-8859-1.

What am I missing? My apache and vhosts config seem to be fine.

url is http://www.pbm.com/~lindahl/union/search.cgi, if you'd like to
play.

-- greg


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] utf8 charset question

Posted by Greg Lindahl <li...@pbm.com>.
On Thu, May 10, 2007 at 05:55:35PM -0400, Joshua Slive wrote:

> CGI scripts get special meta-data treatment because they are capable
> of (and responsible for) setting their own meta-data.

Ah. Then part of the bug is that the documentation for mod_mime
doesn't seem to say this anywhere. And the CGI perl doc managed to
confuse me with the -encoding argument to start_html(), without saying
"Hey, dummy, you have to set the charset in the header() to get a
Content-Type line..."

And that was my bug: I was calling start_html() with an -encoding but
I was not adding -charset to header(). Thus, I was not emitting a
Content-Type header at all.

So my personal problem is solved. And apache 2.0.58 is properly sending
this Content-Type in the headers.

-- greg



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] utf8 charset question

Posted by Joshua Slive <jo...@slive.ca>.
On 5/10/07, Greg Lindahl <li...@pbm.com> wrote:
> On Wed, May 09, 2007 at 03:35:46PM -0400, Joshua Slive wrote:
>
> > In my opinion, that is a bug. Apache should be passing the charset
> > specified by your CGI script in the Content-Type line
>
> But nothing in the docs says that .cgi scripts are treated differently
> from any other file. I'm much more concerned that the .htaccess
> is apparently being ignored, but only for .cgi scripts.

CGI scripts get special meta-data treatment because they are capable
of (and responsible for) setting their own meta-data. For example, the
AddType directive has no effect on CGI scripts either, by design. In
general, I wouldn't expect any of the mod_mime stuff to have any
effect on CGI scripts (except for some special cases). The same
applies to any dynamic content like php scripts or java servlet output
-- mod_mime is ignored because they are responsible for their own
meta-data.

In particular, according the CGI specification, CGI scripts must set
their own Content-Type header. The charset is part of the Content-Type
header, and therefore should be set by the CGI script and passed
through by apache to the client. The fact that this is not happening
is a bug (and a pretty serious one if it is happening generally and
not just in some special cases that we are testing).

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] utf8 charset question

Posted by Greg Lindahl <li...@pbm.com>.
On Wed, May 09, 2007 at 03:35:46PM -0400, Joshua Slive wrote:

> In my opinion, that is a bug. Apache should be passing the charset
> specified by your CGI script in the Content-Type line

But nothing in the docs says that .cgi scripts are treated differently
from any other file. I'm much more concerned that the .htaccess
is apparently being ignored, but only for .cgi scripts.

-- greg


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] utf8 charset question

Posted by Joshua Slive <jo...@slive.ca>.
On 5/9/07, Greg Lindahl <li...@pbm.com> wrote:
> On Wed, May 09, 2007 at 09:33:17AM -0400, Joshua Slive wrote:
> > On 5/9/07, Greg Lindahl <li...@pbm.com> wrote:
> >
> > >If I uncomment any one of the 3 commented lines. my .html pages all
> > >come out utf-8. But, no matter what, my cgi always is iso-8859-1.
> > >
> > >What am I missing? My apache and vhosts config seem to be fine.
> >
> > Have you tried adjusting your CGI script so that the content-type
> > header it emits has the proper charset defined?
>
> It is already doing that. However, it was my impression that this was
> irrelevant to Apache.

In my opinion, that is a bug. Apache should be passing the charset
specified by your CGI script in the Content-Type line. A quick look at
the code suggests it was designed to work that way, but I just tested
it and indeed something ate the charset. I can't figure out what. I
suggest filing a bug report.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] utf8 charset question

Posted by Greg Lindahl <li...@pbm.com>.
On Wed, May 09, 2007 at 09:33:17AM -0400, Joshua Slive wrote:
> On 5/9/07, Greg Lindahl <li...@pbm.com> wrote:
> 
> >If I uncomment any one of the 3 commented lines. my .html pages all
> >come out utf-8. But, no matter what, my cgi always is iso-8859-1.
> >
> >What am I missing? My apache and vhosts config seem to be fine.
> 
> Have you tried adjusting your CGI script so that the content-type
> header it emits has the proper charset defined?

It is already doing that. However, it was my impression that this was
irrelevant to Apache.

-- greg



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] utf8 charset question

Posted by Joshua Slive <jo...@slive.ca>.
On 5/9/07, Greg Lindahl <li...@pbm.com> wrote:

> If I uncomment any one of the 3 commented lines. my .html pages all
> come out utf-8. But, no matter what, my cgi always is iso-8859-1.
>
> What am I missing? My apache and vhosts config seem to be fine.

Have you tried adjusting your CGI script so that the content-type
header it emits has the proper charset defined?

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org