We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf07c80 commit 99cde84Copy full SHA for 99cde84
src/libextra/base64.rs
@@ -237,8 +237,9 @@ impl<'a> FromBase64 for &'a str {
237
}
238
239
for (idx, byte) in it {
240
- if (byte as char) != '=' {
241
- return Err(InvalidBase64Character(self.char_at(idx), idx));
+ match byte as char {
+ '='|'\r'|'\n' => continue,
242
+ _ => return Err(InvalidBase64Character(self.char_at(idx), idx)),
243
244
245
@@ -310,6 +311,8 @@ mod test {
310
311
fn test_from_base64_newlines() {
312
assert_eq!("Zm9v\r\nYmFy".from_base64().unwrap(),
313
"foobar".as_bytes().to_owned());
314
+ assert_eq!("Zm9vYg==\r\n".from_base64().unwrap(),
315
+ "foob".as_bytes().to_owned());
316
317
318
#[test]
0 commit comments