gh-148192: Fix Generator._make_boundary behavior with CRLF line endings.#148193
gh-148192: Fix Generator._make_boundary behavior with CRLF line endings.#148193henryivesjones wants to merge 3 commits intopython:mainfrom
Conversation
The Generator._make_boundary regex does not match on boundary phrases correctly when using CRLF line endings due to re.MULTILINE not considering \r\n as a line ending.
|
The failing test seems to just be flaky? I ran just that one test 4 times and 2 passed and 2 failed. |
| msg = MIMEMultipart() | ||
| msg.attach(MIMEText(boundary_in_part)) | ||
| self.genclass(self.ioclass()).flatten(msg, linesep=linesep) | ||
| # .0 is appended if the boundary was found. |
There was a problem hiding this comment.
Let's be verbose and enhance this comment a bit to make things clearer. How about "Generator checks the message content for the string it is about to use as a boundary ('token' in this test) and when it finds it in our attachment appends .0 to make the boundary it uses unique."
| @@ -0,0 +1,2 @@ | |||
| ``email.generator.Generator._make_boundary`` now correctly finds the | |||
| boundary when using CRLF linesep. | |||
There was a problem hiding this comment.
This description more about the bugfix implementation than the bug. How about "could fail to detect a duplicate boundary string if linesep was not \n. It now correctly detects boundary strings when linesep is \r\n as well."
And, having written that, it occurs to me we could have the same bug if linesep were set to something exotic. Which shouldn't be a problem in practice, but then, neither is this bug ;) I'm sure non-standard linesep would reveal lots of other bugs in the code in that regard as well, though, so let's just ignore that potential issue.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
The Generator._make_boundary regex does not match on boundary phrases correctly when using CRLF line endings due to re.MULTILINE not considering \r\n as a line ending.
Issue: #148192