Base64Decoder does not detect aligned internal padding
See original GitHub issuevar decoder = new DotNext.Buffers.Text.Base64Decoder();
decoder.DecodeFromUtf16("AA==");
decoder.DecodeFromUtf16("AA==");
Expected behavior: an exception is thrown
Actual behavior: no exception is thrown
The best solution is probably to create member bool gotPadding
or similar, set it if buffer[^1] == '='
, and throw exception if gotPadding is set when starting decoding. Also related, it’s possible to save some memory using forbidden states in reservedBuffer
, examples:
- find first null byte/char instead of storing buffer size separately (null bytes are illegal in base64 input anyways)
- use -1 to mean gotPadding = true (end of input stream)
- create separate Utf8Base64Decoder and Utf16Base64Decoder structs holding 4 bytes and 8 bytes buffer
Issue Analytics
- State:
- Created 4 months ago
- Comments:6
Top Results From Across the Web
Why does base64 encoding require padding if the input ...
Base64 concatenation allows encoders to process large chunks in parallel without the burden of aligning the chunk sizes to a multiple of three....
Read more >Base64.Decoder (Java Platform SE 8 )
This class implements a decoder for decoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045. The...
Read more >BASE64Decoder: Error in encoded stream: Oracle Integration
Issue: The issue is because you are trying to map the stringReference to an opaque element as is without doing converting it into...
Read more >Re: Base64 encoding applied to different unicode texts always ...
purpose by grouping symbols). In summary, padding is not required at all by all Base-N encoders/decoders, and non significant whitespace is frequently needed....
Read more >TextView | Android Developers
android:paddingEnd, Sets the padding, in pixels, of the end edge; see ... Return the number of lines of text, or 0 if the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks!
Fixed in 4.12.2 and published.