Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Byte Order Mark as whitespace in regexp #163

subzey opened this Issue Feb 10, 2012 · 5 comments


None yet
3 participants

subzey commented Feb 10, 2012

trim function uses regular expression /\s+/ in order to get all whitespace chars.
There may be a hidden trouble due to the fact ECMA 262-5 marks BOM character (0xFEFF) as whitespace, while ECMA 262-3 doesn't.

For example, '\ufeff fooo' will be trimmed in most modern browsers, and will not be trimmed in Node.js


janl commented Feb 23, 2012

Can you create a test case for this?

subzey commented Feb 28, 2012

Mustache.render("foo{{\uFEFFbar }}", {'bar': 'bar', '\uFEFFbar': 'baz'})

Returns "foobar" in ECMAScript 5 based js engines and returns "foobaz" in ES3 based ones (node.js and IE8 or lower).


janl commented Feb 28, 2012

Sorry, I meant, can you create a pull request that integrates this into our test suite? :)

subzey commented Feb 29, 2012

Here it is: #177
I hope, I did it right way


dasilvacontin commented May 9, 2015

Closed via e54aca8.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment