]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #11652 : hdima/rust/base64-padding-newlines, r=alexcrichton
authorbors <bors@rust-lang.org>
Mon, 20 Jan 2014 06:31:42 +0000 (22:31 -0800)
committerbors <bors@rust-lang.org>
Mon, 20 Jan 2014 06:31:42 +0000 (22:31 -0800)
Ignore all newline characters in Base64 decoder to make it compatible with other Base64 decoders.

Most of the Base64 decoder implementations ignore all newline characters in the input string. There are some examples:

Python:

```python
>>> "
A
Q
=
=
".decode("base64")
'\x01'
```

Ruby:

```ruby
irb(main):001:0> "
A
Q
=
=
".unpack("m")
=> ["\ 1"]
```

Erlang:

```erlang
1> base64:decode("
A
Q
=
=
").
<<1>>
```

Moreover some Base64 encoders append newline character at the end of the output string by default:

Python:

```python
>>> "\ 1".encode("base64")
'AQ==
'
```

Ruby:

```ruby
irb(main):001:0> ["\ 1"].pack("m")
=> "AQ==
"
```

So I think it's fairly important for Rust Base64 decoder to accept Base64 inputs even with newline characters in the padding.


Trivial merge