Re: Safari treats text/html as text/plain



Barry Margolin wrote:
Sander Tekelenburg <user@xxxxxxxxxxxxxx> wrote:
Barry Margolin <barmar@xxxxxxxxxxxx> wrote:
John Chambers <jcsd@xxxxxxxxxxxxx> wrote:
[...]
Content-Type: text/html charset="utf-8"
Shouldn't there be a ";" between text/html and charset?
Yes, I noticed that too, but this seems to have been a typo by the OP:

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.
.



Relevant Pages

  • Re: Need Help with Stalling IE
    ... > Do you know which of those browsers will import Internet Explorer's ... One reason I don't use Safari as my main browser is that I ... > can't transfer my Favorites from IE into Safari's bookmarks. ...
    (comp.infosystems.www.browsers.mac)
  • Re: Javascript Library
    ... jQuery only supports the following browsers: ... Do you have any idea how many agents jQuery will identify as IE? ... in all browsers but Safari. ... libraries keep everything bound indefinitely? ...
    (comp.lang.javascript)
  • Re: Browser Test
    ... Ah that one I could do with, Mac testing is a bit of a hassle for me ... I went to site the other day with Safari on my ... lazy and can't be bothered to design for other browsers, ...
    (alt.2600)
  • Re: Validating a page with W3.org
    ... I tried this and it comes out OK in most browsers, but not Konqueror, ... I have been looking in Safari and when it ... and there is an easy solution there if you know the height of ... easy to manage regular table (there is a small complication that ...
    (alt.html)
  • Re: Browser Test
    ... Ah that one I could do with, Mac testing is a bit of a hassle for me ... I went to site the other day with Safari on my ... lazy and can't be bothered to design for other browsers, ...
    (alt.2600)