… | |
… | |
1237 | around it in every other generator. The above regexes should work well in |
1237 | around it in every other generator. The above regexes should work well in |
1238 | other languages, as long as they operate on UTF-8. It is equally valid to |
1238 | other languages, as long as they operate on UTF-8. It is equally valid to |
1239 | replace all occurences of U+2028/2029 directly by their \\u-escaped forms |
1239 | replace all occurences of U+2028/2029 directly by their \\u-escaped forms |
1240 | in unicode texts, so they can simply be used to fix any parsers relying on |
1240 | in unicode texts, so they can simply be used to fix any parsers relying on |
1241 | C<eval> by first applying the regexes on the encoded texts. |
1241 | C<eval> by first applying the regexes on the encoded texts. |
|
|
1242 | |
|
|
1243 | Note also that the above only works for U+2028 and U+2029 and thus |
|
|
1244 | only for fully ECMAscript-compliant parsers. Many existing javascript |
|
|
1245 | implementations misparse other characters as well. Best rely on a good |
|
|
1246 | JSON parser, such as Douglas Crockfords F<json2.js>, which escapes the |
|
|
1247 | above and many more problematic characters properly before passing them |
|
|
1248 | into C<eval>. |
1242 | |
1249 | |
1243 | Another problem is that some javascript implementations reserve |
1250 | Another problem is that some javascript implementations reserve |
1244 | some property names for their own purposes (which probably makes |
1251 | some property names for their own purposes (which probably makes |
1245 | them non-ECMAscript-compliant). For example, Iceweasel reserves the |
1252 | them non-ECMAscript-compliant). For example, Iceweasel reserves the |
1246 | C<__proto__> property name for it's own purposes. |
1253 | C<__proto__> property name for it's own purposes. |