Skip to content

Decouple encode and decode padding policies for asymmetric protocols #9

Closed

Description

@tisonkun

Context

policy::Padded and policy::Unpadded in bases/src/policy.rs currently control encoding and decoding together: Padded emits and requires canonical = padding, while Unpadded omits and rejects =. Several real-world wire protocols require asymmetric behavior: for example, gRPC HTTP/2 binary metadata specifies that senders should omit padding while receivers must accept both padded and unpadded Base64, and many JWT/OAuth2 implementations accept optional canonical padding on decode. Notably, Base16<Case, DecodeCase> and Base32<Alphabet, Padding, Case, DecodeCase> already separate encode output case from decode case policy.

Considerations

  • Keep the existing ten strict crate-root profiles unchanged as the default contract.
  • Evaluate separating encode padding emission from decode padding acceptance (or adding an explicit policy::Indifferent decode padding marker) on Base64 and Base32.
  • Keep padding acceptance orthogonal to whitespace skipping or non-zero trailing-bit tolerance; specs that bundle all three (such as WHATWG forgiving-base64) have distinct contracts and should not be conflated into a generic lenient mode.

Activity

  1. tisonkun commented on Nov 18, 2026

    @tisonkun
    ContributorAuthor

    Resolved by #21.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions