This repository was archived by the owner on Aug 19, 2025. It is now read-only.
Trim leading contiguous whitespace, fix nightly clippy warns#41
Merged
cpu merged 2 commits intorustls:mainfrom Mar 1, 2024
Merged
Trim leading contiguous whitespace, fix nightly clippy warns#41cpu merged 2 commits intorustls:mainfrom
cpu merged 2 commits intorustls:mainfrom
Conversation
Like we just did in Rustls and webpki, _always_ opt-in to no_std, and then import the std prelude in tests where necessary. This resolves some nightly clippy warnings about redundant imports that will arise otherwise
djc
reviewed
Feb 27, 2024
djc
reviewed
Feb 29, 2024
RFC 7468 §2[0] says: > parsers SHOULD ignore whitespace Previously we only stripped the trailing whitespace from the base64 content lines within the PEM section boundaries. This branch updates our processing to additionally trim leading contiguous whitespace. This felt more sensible than outright ignoring whitespace (e.g. from the middle of content) and will be sufficient to resolve the real world PEM files we've seen with leading whitespace. We base our implementation on the stdlib's unstable `[u8]::trim_ascii` fn, which we can't (yet) use directly due to our MSRV/stable rust requirements. A TODO is left for future cleanup. [0]: https://www.rfc-editor.org/rfc/rfc7468#section-2
db38d3a to
a0f5ad0
Compare
djc
approved these changes
Feb 29, 2024
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
RFC 7468 §2 says:
Previously we only stripped the trailing whitespace from the base64 content lines within the PEM section boundaries. This branch updates our processing to additionally trim leading contiguous whitespace. This felt more sensible than outright ignoring whitespace (e.g. from the middle of content) and will be sufficient to resolve #40
We base our implementation on the stdlib's unstable
[u8]::trim_asciifn, which we can't (yet) use directly due to our MSRV/stable rust requirements. A TODO is left for future cleanup. Notably this broadens our definition of what whitespace is slightly (e.g. including\t).Along the way I noticed CI for main is failing on nightly clippy due to redundant import findings. I've applied the same fix strategy we used for Rustls (rustls/rustls#1813) and Webpki (rustls/webpki#234) to resolve this.