In 1.8, the string "\u2028" is converted to "u2028", so any JSON containing "u2028" would be replaced with "\u2028", and any string literals "\u2028" would not get escaped. This patch uses octet literals if the Ruby version is less than 1.9, and Unicode literals if the Ruby version is 1.9 or greater.
If anyone doesn't like the Ruby version comparison within the code, I can remove the comparison and use the octet literal for all versions of Ruby, because 1.9 interprets "\342\200\250" the same as "\u2028".
Split "should not allow literal U+2028 or U+2029" assigns and tests f…
…or ">= 1.9" and "< 1.9".
Use octets in string literals when translating U+2028 and U+2029 if u…
…sing a Ruby version less than 1.9.
Previously, this would translate "u2028" to "\\u2028", because the \u escape character doesn't exist in 1.8.
Replace Gem::Version comparison with "\u2028" == 'u2028' comparison.
This ensures that the Unicode character is properly translated without relying on Gem::Version. Thanks to @judofyr.
Move U+2028 and U+2029 into constants.
This allows the Ruby compatibility check to be run once on startup rather than for every request. Thanks to @judofyr.
The tests are a little hard to understand unless you've read the comments on this PR. A comment there or more descriptive naming would help.