rustc-serialize icon indicating copy to clipboard operation
rustc-serialize copied to clipboard

Base64: invalid trailing characters when last line ending is near trailer

Open jethrogb opened this issue 5 years ago • 0 comments

This

println!("{:?}", b"foob".to_base64(Config{line_length:Some(4), ..STANDARD}));
println!("{:?}", b"foob".to_base64(Config{line_length:Some(5), ..STANDARD}));
println!("{:?}", b"foob".to_base64(Config{line_length:Some(6), ..STANDARD}));
println!("{:?}", b"foob".to_base64(Config{line_length:Some(7), ..STANDARD}));
println!("{:?}", b"foob".to_base64(Config{line_length:Some(8), ..STANDARD}));

prints

"Zm9v\r\nYg=="
"Zm9vYg===="
"Zm9vYg===="
"Zm9vYg===="
"Zm9vYg=="

This is invalid for line lengths 5~7.

(I'm not expecting this to be fixed but I'm still filing the issue to create awareness)

jethrogb avatar Jul 20 '19 03:07 jethrogb