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"))
with get_mail_fp(entry) as fp:
for line in fp:
if line.startswith(b'.'):
write(b'.') # prepend dot
if line.startswith(b"."):
write(b".") # prepend dot
write(line)
# write(get_mail(entry)) # no prepend dot
write(end())
@ -396,7 +396,7 @@ def debug_main():
_, mails_path, mbox = sys.argv
mails_path = Path(mails_path)
users = [ User(username="dummy", password_hash=gen_pwhash("dummy"), mbox=mbox) ]
users = [User(username="dummy", password_hash=gen_pwhash("dummy"), mbox=mbox)]
asyncio.run(a_main("127.0.0.1", 1101, mails_path, users=users))

View File

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