Repository navigation
Return nil, not false, when a line carries no literal - #790
Open
ihamzatarar wants to merge 1 commit into
Open
ihamzatarar wants to merge 1 commit into
ihamzatarar wants to merge 1 commit into
Conversation
get_literal_size ends in a && chain, so it returned false rather than nil when the line does not end with a literal prefix. read_line stores that in @literal_size before guard_response_too_large! runs, so a line that exceeded max_response_size produced a ResponseTooLargeError whose literal_size was false instead of nil. Nothing else changes: done? and min_response_remaining treat false and nil alike, and response_size_msg already treats false as falsy, so only the attribute value differs.
This branch has not been deployed
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.
Fixes #789.
get_literal_sizeends in a&&chain, so it returnsfalserather thannilwhen the line does not end with a literal prefix:read_lineassigns that to@literal_sizebeforeguard_response_too_large!runs, so when a long line exceedsmax_response_size,ResponseTooLargeError#literal_sizeisfalseinstead ofnil. The v0.5 and v0.4 branches are not affected, because there the error is raised before the assignment.Nothing else changes:
done?andmin_response_remainingboth treatfalseandnilalike, andresponse_size_msgalready treatsfalseas falsy, so only the attribute value differs. That matches theliteral_size: nildefault onResponseTooLargeError#initialize.The guard is the one @znz suggested on the issue.
Tests
One test in
test/net/imap/test_response_reader.rb, covering both halves: an oversized line reports no literal size, and an oversized literal still reports 200. It fails on master with<false> was expected to be nil.Suite on Ruby 3.4.6, run standalone:
test/net/imap/test_stringprep_tables.rbis excluded from that run because it needsrfcs/rfc3454-stringprep_tables.json, which is generated by a rake task rather than checked in. It does not touch this code.