Repository navigation
Fix hang on long MIME boundaries - #151
Merged
staktrace merged 1 commit intoNov 14, 2026
Merged
Conversation
find_from_u8_line_prefix searched for the boundary and then checked for a preceding newline, restarting one byte later after each mid-line miss. A long boundary with similar mid-line text made this quadratic and effectively hang (issue staktrace#148). Search only at line starts so the cost is linear in the message size. If the key itself contains a newline, fall back to the previous search to preserve behaviour. Add a regression test using the issue's reproducer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
find_from_u8_line_prefixsearched for the boundary and then checked for a preceding newline, restarting one byte later after each mid-line miss. A long boundary with similar mid-line text made this quadratic and effectively hang.This walks line starts with
find_byteso the search is linear in the message size. If the key itself contains a newline (which a MIME boundary cannot), it falls back to the previous search to preserve behaviour. A regression test uses the reproducer from the issue.Fixes #148