Skip to content

Zipdownload: fix escaping in Mbox downloads#10151

Open
gurnec wants to merge 3 commits into
roundcube:masterfrom
gurnec:zipdownload-mbox
Open

Zipdownload: fix escaping in Mbox downloads#10151
gurnec wants to merge 3 commits into
roundcube:masterfrom
gurnec:zipdownload-mbox

Conversation

@gurnec

@gurnec gurnec commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Closes #10150.

This unfortunately adds some extra complication... a simpler alternative might be slurp each entire email into a variable and just preg_replace() it all at once in _download_messages(). That would add additional memory overhead though.

@gurnec gurnec force-pushed the zipdownload-mbox branch 2 times, most recently from 7e9bc04 to 9ecb474 Compare May 2, 2026 11:04
@gurnec gurnec force-pushed the zipdownload-mbox branch 3 times, most recently from 0cad7a6 to 9bf4cc5 Compare May 13, 2026 22:44
'INBOX.mbox' => ['From test-from', "\nFrom thomas", "\n>From line which needs to be escaped"],
]);
} finally {
$browser->removeDownloadedFile($filename);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer doing assertions after removing the file. The test files are small so we can keep them in memory.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean something like:

  1. extract filenames / file contents,
  2. remove zip file (no try/finally block required),
  3. do all assertions

probably all in checkFilesInZip()?

Also, just for future reference, would you prefer that I add new commits to this branch, or force-push existing commit(s) to keep the history a bit cleaner?

@alecpl alecpl Jun 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1. extract filenames / file contents,
2. remove zip file (no try/finally block required),
3. do all assertions

probably all in checkFilesInZip()?

Yes, not necessarily in a single method.

Also, just for future reference, would you prefer that I add new commits to this branch, or force-push existing commit(s) to keep the history a bit cleaner?

Doesn't matter, I usually use the "Squash and merge" button.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've simplified the E2E tests w/o changing what is tested, should be better now.

gurnec added 3 commits June 19, 2026 11:06
This checks an Mbox download has a properly escaped From line,
and also checks at least some content of each zipped file
(which as a side effect verifies the zips' CRCs).
@gurnec gurnec force-pushed the zipdownload-mbox branch from 9bf4cc5 to 2183f9a Compare June 19, 2026 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zipdownload's Mbox format does not escape "From " lines

2 participants