The debdiff case was dealt with recently in bug 229040, but it looks like a more general fix is necessary. The problem, afaict, is in the `zope.app.content_types.text_type` function, which does some really awful guessing:
def text_type(s):
s = s.strip()
# Yuk. See if we can figure out the type by content.
if s.lower().startswith('<html>') or '</' in s:
return 'text/html'
elif s.startswith('<?xml'):
return 'text/xml'
else:
return 'text/plain'
We could call `z.a.content_types.guess_content_type` with an explicit default, then `text_type` will never be called. Some people may rely on the fact that real XML and HTML files are currently detected, so a refined version of `text_type` may be needed instead.
The debdiff case was dealt with recently in bug 229040, but it looks like a more general fix is necessary. The problem, afaict, is in the `zope.app. content_ types.text_ type` function, which does some really awful guessing:
def text_type(s): ).startswith( '<html> ') or '</' in s: '<?xml' ):
s = s.strip()
# Yuk. See if we can figure out the type by content.
if s.lower(
return 'text/html'
elif s.startswith(
return 'text/xml'
else:
return 'text/plain'
We could call `z.a.content_ types.guess_ content_ type` with an explicit default, then `text_type` will never be called. Some people may rely on the fact that real XML and HTML files are currently detected, so a refined version of `text_type` may be needed instead.