Skip to content

Conversation

@marximimus
Copy link
Contributor

No description provided.

@jedisct1
Copy link
Contributor

jedisct1 commented Nov 6, 2025

If it doesn't, this is probably because it hasn't been implemented yet.

But if after skipping the ignored chars, the length is inconsistent with the required padding (for variants that require padding), I'd expect that function to return InvalidPadding as the comment suggests.

@marximimus
Copy link
Contributor Author

marximimus commented Nov 6, 2025

I don't think this function should return InvalidPadding for any source_len. The source can consist entirely of ignored chars.

@marximimus
Copy link
Contributor Author

I forgot to change the doc comment, tho. I'll fix it.

@jedisct1
Copy link
Contributor

jedisct1 commented Nov 6, 2025

If the input contains only ignored characters, it returns 0.

However, if the input length is not valid for padded Base64 and cannot be decoded, then returning an error is expected.

This is trivial to fix: https://gist.github.com/jedisct1/8ea5328ff856a5350432d21f69b78153

So I would prefer to fix the root cause rather than introduce a different breaking change that doesn't really help applications.

@jedisct1
Copy link
Contributor

jedisct1 commented Nov 6, 2025

Or that can be two different functions, one that just takes the length (but in that case, update the function comment) and another one that takes the string.

@marximimus
Copy link
Contributor Author

I think those should be two separate functions.

@marximimus
Copy link
Contributor Author

Base64Decoder has calcSizeUpperBound (which takes length) and calcSizeForSlice (which takes a slice).

@jedisct1
Copy link
Contributor

jedisct1 commented Nov 6, 2025

Oh nice, I forgot about calcSizeForSlice.

In that case, can you just update the function description to reflect the change?

@jedisct1 jedisct1 merged commit 2e8f8af into ziglang:master Nov 7, 2025
9 checks passed
@jedisct1 jedisct1 added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library. labels Nov 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Implementing this issue could cause existing code to no longer compile or have different behavior. standard library This issue involves writing Zig code for the standard library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants