Issue 9543 - Base64.decode shouldn't require source to have known length
Summary: Base64.decode shouldn't require source to have known length
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P3 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-19 18:21 UTC by Nick Sabalausky
Modified: 2024-12-01 16:16 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Nick Sabalausky 2013-02-19 18:21:57 UTC
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.
Comment 1 monarchdodra 2013-07-05 06:54:07 UTC
+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
Comment 2 dlangBugzillaToGithub 2024-12-01 16:16:33 UTC
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/phobos/issues/9953

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB