nitrogen / simple_bridge

A simple, standardized interface library to Erlang HTTP Servers.
MIT License
112 stars 76 forks source link

Update cowboy_simple_bridge_anchor.erl #42

Closed homeway closed 9 years ago

homeway commented 9 years ago

erlang:iolist_to_binary/1 can't work for utf8, instead of it with unicode:characters_to_binary/1

choptastic commented 9 years ago

Hi,

This actually needs to be done at the framework level rather than at the bridge level. An IOList needs to be transmitted here in order to prevent issues. The main issue is if the user is transmitting binary data (say a dynamically generated image or something), running that binary data through unicode:characters_to_binary/1 will end up either erroring (since it's invalid UTF) or corrupting the contents (if the binary does happen to be encodable as UTF).

I originally thought that this was where it needed to happen to, until I encountered exactly this issue. That's exactly what this test is checking for:

https://github.com/nitrogen/NitrogenProject.com/blob/master/src/tests/tests_disable_encoding.erl

In that, it loads a dynamically generated image of the Nitrogen logo and verifies that the height and width are the expected values.

-Jesse

On Sat, Dec 27, 2014 at 11:34 PM, 青天揽日月 notifications@github.com wrote:

erlang:iolist_to_binary/1 can't work for utf8, instead of it with

unicode:characters_to_binary/1

You can merge this Pull Request by running

git pull https://github.com/homeway/simple_bridge patch-1

Or view, comment on, or merge it at:

https://github.com/nitrogen/simple_bridge/pull/42 Commit Summary

  • Update cowboy_simple_bridge_anchor.erl

File Changes

Patch Links:

— Reply to this email directly or view it on GitHub https://github.com/nitrogen/simple_bridge/pull/42.

Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm

choptastic commented 9 years ago

Closing this, as it was fixed in Nitrogen.