[Zope-CMF] Some views don't set the content-type
Tres Seaver
tseaver at palladion.com
Mon Apr 5 13:17:13 EDT 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Charlie Clark wrote:
> Am 01.04.2010, 08:29 Uhr, schrieb Charlie Clark <charlie at begeistert.org>:
>
>> I'm not sure if this is a CMF or Zope bug but some views, such as
>> folder/view.html do not set the content-type properly which I think
>> causes
>> problems for some browsers. If this is a bug, how can I about fixing it?
>
> After some more investigation I think this is a bug in
> zope.pagetemplatefile: content sniffing only takes the <meta> tags for
> content-type into account. Encoding will be set according to portal rules
> but the comnbination can cause problems for some browsers (Firefox, at
> least, ignores the charset and assumes latin-1). Furthermore, the
> behaviour varies between the "classic" rendering and views. As views can
> be configured without a dedicated class I can't see a CMF solution to this.
>
> To test simply add some non-ascii to the "ursa" or "were" main_templates
> and call the @@view.html in Firefox. For some reason CMFDefault's
> @@view.html still renders correctly. I guess this must be related to the
> __init__ in ursa globals. This probably needs patching so the behaviour is
> the same. At least we've got tests for this.
>
> I don't think depending on the meta declaration is the right approach.
> I've seen it used incorrectly very often and it's supposed to be a hint
> for the browser but will be overridden by the content-type in the header.
For a template, the <meta> tag should be correct, if present. No
template cxcept for the main_template is likely ever to return that tag
to the browser, but there is no reason we shouldn't believe it when
loading the template as software. I wouldn't require *any* template
outside the main_template to set the DOCTYPE: the potential for bugs in
how ZPT (or chameleon) merge the "prefixes" of the documents is too high.
> Better to add proper detection for the HTML Doctype in
> zope.pagetemplate.pagetemplatefile. I'm not sure about the charset - I
> think there's a way to check for the character encoding "manually" using
> the BOM and this should be used with the meta declaration as a fall-back
> and there should be an error if there is a mismatch. Should I submit a bug
> on this
Tres.
- --
===================================================================
Tres Seaver +1 540-429-0999 tseaver at palladion.com
Palladion Software "Excellence by Design" http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAku6GxUACgkQ+gerLs4ltQ6GcACgqliXU6Hie75DDcb0v8npsCV7
X5gAniylhkopkjr0whYzd9FVFBk+iucB
=9XWr
-----END PGP SIGNATURE-----
More information about the Zope-CMF
mailing list