Re: Safari treats text/html as text/plain
- From: John Chambers <jcsd@xxxxxxxxxxxxx>
- Date: Wed, 12 Apr 2006 10:08:51 -0400
Barry Margolin wrote:
Sander Tekelenburg <user@xxxxxxxxxxxxxx> wrote:Barry Margolin <barmar@xxxxxxxxxxxx> wrote:John Chambers <jcsd@xxxxxxxxxxxxx> wrote:[...]Yes, I noticed that too, but this seems to have been a typo by the OP:Content-Type: text/html charset="utf-8"Shouldn't there be a ";" between text/html and charset?
Typo? It looks like he cut/pasted, so I didn't think a typo was likely.
$ curl -I http://roaringjelly.org/~jc/acct/login.cgi
[...]
Content-Type: text/html; charset=UTF-8
Maybe he's already fixed it.
Maybe; maybe not. I tried checking out the origin of the line without
the ';', but found that 1) my code now generates the ';', and 2) the page
now works with Safari.
As so often happens, my thought was "But I haven't changed the code!"
Standard disclaimer. I had, of course, done a fair amount of tweaking
of other stuff, to try to get some clues. But the perl code that generates
the header was unchanged:
$charset = 'UTF-8';
$mimetype = 'text/html';
....
my $cgi = new CGI;
print $cgi->header(
'-type' => $mimetype,
'-charset' => $charset,
'-expires' => '+30s',
);
The $mimetype var doesn't contain a ';'; it's just 'text/html', and the
$charset var is 'UTF-8'. I have changed charset back and forth between
'UTF-8' and 'utf-8', as a way of verifying that those 5 chars really were
coming from $charset and not being generated by some subroutine.
I also change the '-expires' value occasionally for the same reason.
But note that no string in my code contains a ';' char, so it is generated
by some subroutine. At least it is now, though apparently a couple of
days ago it wasn't.
This ';' probably is the problem. I suppose I have it narrowed down to
some flakiness in the perl CGI module. I'm not sure how to pin it down
further. So whatever triggered it will presumably reappear some time
in the future. I wonder if there's a way to automatically spot it when it
happens again? The only way I know is to test it with Safari, which is
in my set of test browsers, but far from the only one. I guess I'll just have
to make a note that Safari is the only browser I have that cares whether
there's a ';' between the MIME type and the charset= chunks, and sudden
failure for Safari to recognize text/html might be because this ';' has
disappeared for some reason.
It's yet another reason why, after prototyping things like this, I tend to
go over it and replace calls on library routines with my own code that
does the low-level operation directly. It's more efficient to just write the
HTTP headers directly, and it's not subject to this sort of weirdness.
Anyway, thanks to the pointers to that ';'. It's really hard to see things
like that, especially when most of the browsers don't seem to care whether
it's there or not.
And this is a case where, if I didn't have a Mac available for testing,
I'd never have noticed a problem. I even tested it against IE on my
wife's Windows box, and it worked fine there without the ';'. So it's
yet another example of why web testing needs a flock of different
machines, browsers, etc. I do test against w3c's validator, but
not for every 1-line change to the code, so maybe I'd have found the
problem there eventually. In this case, though, the obvious first
question is "Why does Safari treat this page differently from the
dozen or so other browsers I'd tried it with?" So the obvious place
to ask was in a forum where Safari hackers might hang out.
.
- Follow-Ups:
- Re: Safari treats text/html as text/plain
- From: Sander Tekelenburg
- Re: Safari treats text/html as text/plain
- References:
- Safari treats text/html as text/plain
- From: John Chambers
- Re: Safari treats text/html as text/plain
- From: Barry Margolin
- Re: Safari treats text/html as text/plain
- From: Sander Tekelenburg
- Re: Safari treats text/html as text/plain
- From: Barry Margolin
- Safari treats text/html as text/plain
- Prev by Date: Re: What do you think of Apple Remote Desktop 3?
- Next by Date: What do you think of Apple Remote Desktop 3?
- Previous by thread: Re: Safari treats text/html as text/plain
- Next by thread: Re: Safari treats text/html as text/plain
- Index(es):
Relevant Pages
|