Commit 3fb994c2 authored by 's avatar

Merged fix for setBase breaking when content-type has a charset attribute

assigned.
parent 83fc6309
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
############################################################################## ##############################################################################
'''CGI Response Output formatter '''CGI Response Output formatter
$Id: HTTPResponse.py,v 1.31 2000/06/28 14:11:02 brian Exp $''' $Id: HTTPResponse.py,v 1.32 2000/08/07 17:15:25 brian Exp $'''
__version__='$Revision: 1.31 $'[11:-2] __version__='$Revision: 1.32 $'[11:-2]
import string, types, sys, regex, re import string, types, sys, regex, re
from string import find, rfind, lower, upper, strip, split, join, translate from string import find, rfind, lower, upper, strip, split, join, translate
...@@ -328,8 +328,9 @@ class HTTPResponse(BaseResponse): ...@@ -328,8 +328,9 @@ class HTTPResponse(BaseResponse):
base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)', base_re_search=regex.compile('\(<base[\0- ]+[^>]+>\)',
regex.casefold).search regex.casefold).search
): ):
if (self.headers.has_key('content-type') and # Only insert a base tag if content appears to be html.
self.headers['content-type'] != 'text/html'): return if self.headers.get('content-type', '')[:9] != 'text/html':
return
if self.base: if self.base:
body=self.body body=self.body
...@@ -688,7 +689,8 @@ class HTTPResponse(BaseResponse): ...@@ -688,7 +689,8 @@ class HTTPResponse(BaseResponse):
c='text/plain' c='text/plain'
self.setHeader('content-type',c) self.setHeader('content-type',c)
else: else:
isHTML = headers['content-type']=='text/html' isHTML = headers['content-type'][:9] == 'text/html'
if isHTML and end_of_header_search(self.body) < 0: if isHTML and end_of_header_search(self.body) < 0:
lhtml=html_search(body) lhtml=html_search(body)
if lhtml >= 0: if lhtml >= 0:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment