Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.14]: Fix: Fold long lines during SMTP communication #140

Merged
merged 16 commits into from
Mar 17, 2021

Commits on Mar 15, 2021

  1. Fold long lines following RFC 5322 section-2.2.3

    To deal with the 998/78 character limitations per line,
    long lines can be split into a multiple-line representation
    separated by CRLF + WSP; this is called "folding".
    Correct folding is particularly important for long header fields.
    
    Signed-off-by: Vlad Safronov <[email protected]>
    vladsf authored and glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    8512e5d View commit details
    Browse the repository at this point in the history
  2. Use Headers::FOLDING when folding

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    7bc2deb View commit details
    Browse the repository at this point in the history
  3. Use fgets and detect partial line reads

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    44c4053 View commit details
    Browse the repository at this point in the history
  4. Add unit test for long header wrapping

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    009eed6 View commit details
    Browse the repository at this point in the history
  5. Refactor data reader in Protocol\Smtp to use Generator

    This isolates the logic of handling incomplete reads to own unit.
    
    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    3dab0b3 View commit details
    Browse the repository at this point in the history
  6. Optimize out strlen call

    As the buffer max size is known, can check last byte with isset
    
    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    662433d View commit details
    Browse the repository at this point in the history
  7. Test for max length of all SMTP data lines

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    fb82a12 View commit details
    Browse the repository at this point in the history
  8. Move chunkedReader to a method

    he method has no state, so therefore declared static.
    Ideally this should be a standalone class, perhaps in laminas-stdlib.
    
    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    0deb254 View commit details
    Browse the repository at this point in the history
  9. Update chunk_split to use 997 for correct result

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    a3e57fd View commit details
    Browse the repository at this point in the history
  10. Update test that header line with exact length is not wrapped

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    b40d5d4 View commit details
    Browse the repository at this point in the history
  11. Update test to require lines not to be empty

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    38bc378 View commit details
    Browse the repository at this point in the history
  12. Add MAX_LINE_LENGTH constant for magic 998 value

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    43d8da3 View commit details
    Browse the repository at this point in the history
  13. Update test to use SmtpProtocol::MAX_LINE_LENGTH constant

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    4105ce6 View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    db94751 View commit details
    Browse the repository at this point in the history
  15. Rename MAX_LINE_LENGTH -> SMTP_LINE_LIMIT

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    b93be75 View commit details
    Browse the repository at this point in the history
  16. Update test to expect Headers::FOLDING never change

    Signed-off-by: Elan Ruusamäe <[email protected]>
    glensc committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    74f4242 View commit details
    Browse the repository at this point in the history