Ejemplo n.º 1
0
    def test_encoding_utf_8_header_parameters(self):
        from repoze.sendmail._compat import b
        from repoze.sendmail._compat import quote
        utf_8_encoded = b('mo \xe2\x82\xac')
        utf_8 = utf_8_encoded.decode('utf-8')
        message = self._makeMessage()
        message['Content-Disposition'] = ('attachment; filename=' + utf_8 +
                                          '.ppt')

        encoded = self._callFUT(message)

        self.assertTrue(
            b("Content-Disposition: attachment; filename*=") in encoded)
        self.assertTrue(
            b("utf-8''") + quote(utf_8_encoded).encode('ascii') in encoded)
Ejemplo n.º 2
0
    def test_encoding_latin_1_header_parameters(self):
        from repoze.sendmail._compat import b
        from repoze.sendmail._compat import quote
        latin_1_encoded = b('LaPe\xf1a')
        latin_1 = latin_1_encoded.decode('latin_1')
        message = self._makeMessage()
        message['Content-Disposition'] = (
            'attachment; filename=' + latin_1 + '.ppt')

        encoded = self._callFUT(message)

        self.assertTrue(
            b("Content-Disposition: attachment; filename*=") in encoded)
        self.assertTrue(b("latin_1''") + quote(latin_1_encoded).encode('ascii')
                        in encoded)
Ejemplo n.º 3
0
    def test_encoding_utf_8_header_parameters(self):
        from repoze.sendmail._compat import b
        from repoze.sendmail._compat import quote
        utf_8_encoded = b('mo \xe2\x82\xac')
        utf_8 = utf_8_encoded.decode('utf-8')
        message = self._makeMessage()
        message['Content-Disposition'] = (
            'attachment; filename=' + utf_8 + '.ppt')

        encoded = self._callFUT(message)

        self.assertTrue(
            b("Content-Disposition: attachment; filename*=") in encoded)
        self.assertTrue(b("utf-8''") + quote(utf_8_encoded).encode('ascii')
                        in encoded)
Ejemplo n.º 4
0
    def test_encoding_latin_1_header_parameters(self):
        from repoze.sendmail._compat import b
        from repoze.sendmail._compat import quote
        latin_1_encoded = b('LaPe\xf1a')
        latin_1 = latin_1_encoded.decode('iso-8859-1')
        message = self._makeMessage()
        message['Content-Disposition'] = (
            'attachment; filename=' + latin_1 + '.ppt')

        encoded = self._callFUT(message)
        
        self.assertTrue(
            b("Content-Disposition: attachment; filename*=") in encoded)
        self.assertTrue(b("iso-8859-1''") + quote(latin_1_encoded).encode('ascii')
                        in encoded)