Server IP : 85.214.239.14 / Your IP : 216.73.216.26 Web Server : Apache/2.4.65 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 8.2.29 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/self/root/srv/modoboa/env/lib64/python3.5/site-packages/modoboa/lib/tests/ |
Upload File : |
"""Tests for u2u_decode.""" from django.test import TestCase from .. import u2u_decode class U2UTestCase(TestCase): """Test RFC1342 decoding utilities.""" def test_header_decoding(self): """Simple decoding.""" samples = [ ("=?ISO-8859-15?Q?=20Profitez de tous les services en ligne sur " "impots.gouv.fr?=", "Profitez de tous les services en ligne sur impots.gouv.fr"), ("=?ISO-8859-1?Q?Accus=E9?= de =?ISO-8859-1?Q?r=E9ception?= de " "votre annonce", "Accusé de réception de votre annonce"), ("Sm=?ISO-8859-1?B?9g==?=rg=?ISO-8859-1?B?5Q==?=sbord", "Sm\xf6rg\xe5sbord"), # The following case currently fails because of the way we split # encoded words to parse them separately, which can lead to # unexpected unicode decode errors... I think it will work fine on # Python3 # ("=?utf-8?B?VMOpbMOpcMOpYWdlIFZJTkNJIEF1dG9yb3V0ZXMgLSBFeHDD?=\n" # "=?utf-8?B?qWRpdGlvbiBkZSB2b3RyZSBjb21tYW5kZSBOwrAgMjAxNzEyMDcw" # "MDA1?=\n=?utf-8?B?MyBkdSAwNy8xMi8yMDE3IDE0OjQ5OjQx?=", # "") ] for sample in samples: self.assertEqual(u2u_decode.u2u_decode(sample[0]), sample[1]) def test_address_header_decoding(self): """Check address decoding.""" mailsploit_sample = ( "=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?==?utf-8?Q?=00?=" "=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?=@mailsploit.com") expected_result = ( "=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?==?utf-8?Q??=" "=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?=@mailsploit.com") self.assertEqual( u2u_decode.decode_address(mailsploit_sample), ("", expected_result) ) mailsploit_sample = ( '"=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?==?utf-8?Q?=0A=00?="\n' "<=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?==?utf-8?Q?=0A=00?=" "@mailsploit.com>") expected_result = ( "potus@whitehouse.gov", "=?utf-8?b?cG90dXNAd2hpdGVob3VzZS5nb3Y=?==?utf-8?Q??=" "@mailsploit.com") self.assertEqual( u2u_decode.decode_address(mailsploit_sample), expected_result)