pop3 should byte-stuff lines starting with dot #5

Merged
balki merged 4 commits from popdotstuff into main 2024-04-01 17:51:23 -04:00
2 changed files with 7 additions and 6 deletions
Showing only changes of commit ed8ff2728f - Show all commits

View File

@ -219,8 +219,8 @@ def trans_command_retr(mails: MailList, req: Request) -> None:
write(ok("Contents follow")) write(ok("Contents follow"))
with get_mail_fp(entry) as fp: with get_mail_fp(entry) as fp:
for line in fp: for line in fp:
if line.startswith(b'.'): if line.startswith(b"."):
write(b'.') # prepend dot write(b".") # prepend dot
write(line) write(line)
# write(get_mail(entry)) # no prepend dot # write(get_mail(entry)) # no prepend dot
write(end()) write(end())

View File

@ -218,14 +218,15 @@ class TestPop3(unittest.IsolatedAsyncioTestCase):
pc = poplib.POP3("127.0.0.1", 7995) pc = poplib.POP3("127.0.0.1", 7995)
try: try:
self.assertEqual(b"+OK Server Ready", pc.getwelcome()) self.assertEqual(b"+OK Server Ready", pc.getwelcome())
self.assertEqual(b'+OK Welcome', pc.user("foo2")) self.assertEqual(b"+OK Welcome", pc.user("foo2"))
self.assertEqual(b'+OK Login successful', pc.pass_("helloworld")) self.assertEqual(b"+OK Login successful", pc.pass_("helloworld"))
_, eml, oc = pc.retr(1) _, eml, oc = pc.retr(1)
self.assertIn(b"Previous line just has a dot", eml) self.assertIn(b"Previous line just has a dot", eml)
self.assertIn(b".Line starts with a dot", eml) self.assertIn(b".Line starts with a dot", eml)
self.assertIn(b".", eml) self.assertIn(b".", eml)
finally: finally:
pc.quit() pc.quit()
await asyncio.to_thread(run_poplib) await asyncio.to_thread(run_poplib)
async def asyncTearDown(self) -> None: async def asyncTearDown(self) -> None: