mojombo / mustache.erl

Mustache template engine for Erlang.
MIT License
239 stars 59 forks source link

Proper escaping in regexes #12

Closed dLuna closed 11 years ago

dLuna commented 12 years ago

In Erlang "}" doesn't make sense in a string so I removed all those.

Second commit fixes a missing \ to properly escape the '.'.

The third commit I'm not 100% sure about, but it seems likely that you want to match on all whitespace. \s means literal space in a string and will be treated as such in the regex. \s means \s to the regex which will match [\s\t\r\n](i.e. space, tab, cr, lf).

dLuna commented 11 years ago

Ping?

pusewicz commented 11 years ago

@dLuna Thanks for the pull request, but it would be great if you added a test case for it, so we can see it fixing the issue.

pusewicz commented 11 years ago

@dLuna Ping?

dLuna commented 11 years ago

I didn't fix any real issues per se. It's not broken, just very bad coding style.

As an example using "\s" in a regex pattern literally means " ". Using "\s" means "[\t\s\r\n]". Very different things, but since most whitespace is " " not really a problem.

Read the diffs and take the patch or not. Your choice.

dLuna commented 11 years ago

Same thing with escaping {. { in an erlang string is exactly the same thing as {. Just harder to read.

pusewicz commented 11 years ago

Ok, could you rebase against newest master?

dLuna commented 11 years ago

Fixed.

pusewicz commented 11 years ago

Thanks!