HugoGiraudel/SassyJSON — pull request #41 by CrocoDillon (2014-01-23 02:35:26+00:00)
Title: More sophisticated string handling and validation.

A better way for handling string, though only the position of the first non escaped quote is needed. This implementation matches Mozilla’s implementation more closely, iterating over the whole string from the start to keep track of what is really escaped.

Just checking if a quote is preceded by a backslash isn’t enough, since that backslash can be escaped itself.

Additionally, handles invalid escaped characters and code units. I don’t know what to do in these cases, so I just returned 0.

I had to update some tests that were, In my opinion, giving false failures. This is purely subject to how you interpret failure though. Matching the exact JavaScript behavior is impossible, because in Sass only quotes get escaped. For example in JavaScript entering `"\\\""` will result in the string `"\""` (escaped quote) while in Sass it results in the string `"\\""` (escaped backslash, unescaped quote).