Rails escape_javascript creates invalid JSON by escaping single quotes

前端 未结 5 1365
悲&欢浪女
悲&欢浪女 2021-02-07 05:54

The escape_javascript method in ActionView escapes the apostrophe \' as backslash apostrophe \\\', which gives errors when parsing as JSON.

For

5条回答
  •  滥情空心
    2021-02-07 06:36

    May need more details here, but JSON strings must use double quotes. Single quotes are okay in JavaScript strings, but not in JSON.

提交回复
热议问题