Skip to content

Tighten encode/base64 compliance with RFC4648 - #5597

Open
redvers wants to merge 3 commits into
mainfrom
fix_base64_encode_url
Open

redvers wants to merge 3 commits into
mainfrom
fix_base64_encode_url

Conversation

@redvers

@redvers redvers commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Previously, instead of omitting the padding (default '='), it would pad with NUL. Pony Strings do not terminate on NUL, so this resulted in incorrect results:

use "encode/base64"

actor Main
  new create(env: Env) =>
    let a: String = Base64.encode_url("pony")

    /* Outputs: [cG9ueQ]: size=8 */
    env.out.print("[" + a + "]: size=" + a.size().string())

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Jun 28, 2026
@redvers redvers added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Jun 28, 2026
@ponylang-main

Copy link
Copy Markdown
Contributor

Hi @redvers,

The changelog - fixed label was added to this pull request; all PRs with a changelog label need to have release notes included as part of the PR. If you haven't added release notes already, please do.

Release notes are added by creating a uniquely named file in the .release-notes directory. We suggest you call the file 5597.md to match the number of this pull request.

The basic format of the release notes (using markdown) should be:

## Title

End user description of changes, why it's important,
problems it solves etc.

If a breaking change, make sure to include 1 or more
examples what code would look like prior to this change
and how to update it to work after this change.

Thanks.

@redvers redvers changed the title Fix Base64.encode_url() to actually omit padding Fix Base64.encode_url() to omit padding Jun 29, 2026
@redvers
redvers force-pushed the fix_base64_encode_url branch from ebb9efc to 6d20582 Compare June 29, 2026 02:37
@SeanTAllen SeanTAllen added the do not merge This PR should not be merged at this time label Jun 29, 2026
@SeanTAllen

Copy link
Copy Markdown
Member

This is really two different changes. The release notes even state it with a "o btw". I think this should be broken into two different discussions. The bug fix and the API widening.

@SeanTAllen

Copy link
Copy Markdown
Member

Please replace the new example based test with property based tests.

Remove superfloruous arguments to `Base64.encode` which allowed it to
generate output that was contrary to RFC4648.

RFC4648 "base64url" encoding (RFC4648 §5) permits the result to be
padded or not.  Previously, if you asked for a non-padded output the
function would return NUL characters where the padding character would
have been if it were padded.

As Pony Strings do not terminate on NUL, this resulted in incorrect results:

```pony
use "encode/base64"

actor Main
  new create(env: Env) =>
    let a: String = Base64.encode_url("pony")

    /* Outputs: [cG9ueQ]: size=8 */
    env.out.print("[" + a + "]: size=" + a.size().string())
```
@redvers
redvers force-pushed the fix_base64_encode_url branch from 6d20582 to 9cd737c Compare July 5, 2026 19:42
@redvers redvers changed the title Fix Base64.encode_url() to omit padding Tighten encode/base64 compliance with RFC4648 Jul 5, 2026
@redvers redvers removed the do not merge This PR should not be merged at this time label Jul 5, 2026
@SeanTAllen SeanTAllen removed the discuss during sync Should be discussed during an upcoming sync label Aug 19, 2026
@SeanTAllen

Copy link
Copy Markdown
Member

@redvers is this ready for another review?

@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Aug 19, 2026
@redvers

redvers commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

I do not rememeber. Skip it for today and I'll check after this school appointment I have for the kid.

@redvers redvers removed the discuss during sync Should be discussed during an upcoming sync label Aug 26, 2026
@SeanTAllen SeanTAllen added the do not merge This PR should not be merged at this time label Sep 19, 2026

This branch has not been deployed

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

Labels

changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge do not merge This PR should not be merged at this time

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants