Ticket #10188: badheader.diff

File badheader.diff, 827 bytes (added by Bob Thomas, 16 years ago)
  • http/__init__.py

     
    263263        cookiedict[key] = c.get(key).value
    264264    return cookiedict
    265265
     266class BadHeaderError(ValueError):
     267    pass
     268
    266269class HttpResponse(object):
    267270    """A basic HTTP response, with content and dictionary-accessed headers."""
    268271
     
    301304    def _convert_to_ascii(self, *values):
    302305        """Converts all values to ascii strings."""
    303306        for value in values:
     307            if '\n' in value or '\r' in value:
     308                raise BadHeaderError("Header values can't contain newlines (got %r)" % (value))
    304309            if isinstance(value, unicode):
    305310                try:
    306311                    yield value.encode('us-ascii')
Back to Top