mozilla/rust — pull request #11652 by hdima (2014-01-18 19:00:24+00:00)
Title: Ignore all newline characters in Base64 decoder

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
>>> "\nA\nQ\n=\n=\n".decode("base64")
'\x01'
```

Ruby:

```ruby
irb(main):001:0> "\nA\nQ\n=\n=\n".unpack("m")
=> ["\001"]
```

Erlang:

```erlang
1> base64:decode("\nA\nQ\n=\n=\n").
<<1>>
```

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

Python:

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

Ruby:

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

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