Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 160

Show
Ignore:
Timestamp:
04/25/05 04:11:46
Author:
rdelon
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/lib/filter/tidyfilter.py

    r108 r160  
    5151        cpg.response.body = [originalBody] 
    5252         
    53         ct = cpg.response.headerMap.get('Content-Type').split(';')[0] 
     53        fct = cpg.response.headerMap.get('Content-Type', '') 
     54        ct = fct.split(';')[0] 
    5455        if ct == 'text/html': 
    5556            pageFile = os.path.join(self.tmpDir, 'page.html') 
     
    5960            f.write(originalBody) 
    6061            f.close() 
    61             encoding = cpg.response.headerMap.get('Content-Encoding', '') 
     62            encoding = '' 
     63            i = fct.find('charset=') 
     64            if i != -1: 
     65                encoding = fct[i+8:] 
     66            encoding = encoding.replace('utf-8', 'utf8') 
    6267            if encoding: 
    63                 encoding = '-u' + encoding 
     68                encoding = '-' + encoding 
    6469            os.system('"%s" %s -f %s -o %s %s' % ( 
    6570                self.tidyPath, encoding, errFile, outFile, pageFile)) 

Hosted by WebFaction

Log in as guest/cpguest to create tickets