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

Base64.decode shouldn't require source to have known length #9953

Open
dlangBugzillaToGithub opened this issue Feb 19, 2013 · 1 comment
Open

Comments

@dlangBugzillaToGithub
Copy link

bus_dbugzilla reported this on 2013-02-19T18:21:57Z

Transfered from https://issues.dlang.org/show_bug.cgi?id=9543

CC List

  • monarchdodra

Description

A known source length, when it exists, should certainly still be used to:

A. Optimize the output buffer's allocation (when an output range or buffer isn't already provided).

B. Verify sufficient output length in the case of a user-provided output array.

Both of which std.base64 already does.

However, a known source length shouldn't be *required*, because the algorithm itself doesn't require it. When the source length doesn't exist, decode can (and should) simply continue until source.empty is true.

Additionally, if the source length isn't known, and the user didn't provide an output range/buffer, then std.array.Appender should be used instead of a pre-allocated array.

I may put together a pull request for this if I get a chance.
@dlangBugzillaToGithub
Copy link
Author

monarchdodra commented on 2013-07-05T06:54:07Z

+1.

I had to deactivate a wrong-usage unittest in base64. It was trying to test "input range", using map, which erroneously forwarded string length.

I fixed *that*, and the test blew up. So I deactivated it.

https://github.com/D-Programming-Language/phobos/pull/1389

@LightBender LightBender removed the P3 label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants