Server IP : 85.214.239.14 / Your IP : 18.191.154.143 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | 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)