diff --git a/BREAKING_CHANGES.md b/BREAKING_CHANGES.md index bc3161d739..07a2ea5244 100644 --- a/BREAKING_CHANGES.md +++ b/BREAKING_CHANGES.md @@ -87,6 +87,29 @@ invokeMethod() non-virtual forces users to add methods with setMethod() instead of overriding invokeMethod(), which is more compatible with QuickJS. +## Change + +The ASCII and Unicode BEL character (U+0007) escape sequence has changed in the +JSON encoder from "\a" to "\u0007". + +**Possible Issues** + +Reliance on the raw JSON encoded string literal, for example for file comparison, +base-64 encoding, or any encryption, may result in false negatives for JSON data +containing a BEL character between versions of JUCE. + +**Workaround** + +Use string replace, for example call `replace ("\\u007", "\\a")` on the +resulting JSON string to match older versions of JUCE. + +**Rationale** + +The JSON specification does not state that the BEL character can be escaped +using "\a". Therefore other JSON parsers incorrectly read this character when +they encounter it. + + ## Change The LowLevelGraphicsPostscriptRenderer has been removed. @@ -104,7 +127,7 @@ into your own project/module and use them that way. **Rationale** We are not aware of any projects using this functionality. This renderer was -not as fully-featured as any of the other renders, so it's likely that users +not as fully-featured as any of the other renderers, so it's likely that users would have filed issue reports if they were using this feature. @@ -545,14 +568,14 @@ implementation wrapping the QuickJS engine. **Possible Issues** Code that previously successfully evaluated using JavascriptEngine::evaluate() -or JavascriptEngine::execute(), could now fail due to the rules applied by the -new, much more standards compliant engine. One example is object literals +or JavascriptEngine::execute(), could now fail due to the rules applied by the +new, much more standards compliant engine. One example is object literals e.g. { a: 'foo', b: 42, c: {} }. When evaluated this way the new engine will assume that this is a code block and fail. **Workaround** -When calling JavascriptEngine::evaluate() or JavascriptEngine::execute() the +When calling JavascriptEngine::evaluate() or JavascriptEngine::execute() the code may have to be updated to ensure that it's correct according to the Javascript language specification and in the context of that evaluation. Object literals standing on their own for example should be wrapped in parentheses diff --git a/modules/juce_core/javascript/juce_JSON.cpp b/modules/juce_core/javascript/juce_JSON.cpp index d018b69419..44a677549a 100644 --- a/modules/juce_core/javascript/juce_JSON.cpp +++ b/modules/juce_core/javascript/juce_JSON.cpp @@ -333,14 +333,13 @@ struct JSONFormatter { case 0: return; - case '\"': out << "\\\""; break; - case '\\': out << "\\\\"; break; - case '\a': out << "\\a"; break; - case '\b': out << "\\b"; break; - case '\f': out << "\\f"; break; - case '\t': out << "\\t"; break; - case '\r': out << "\\r"; break; - case '\n': out << "\\n"; break; + case '\"': out << "\\\""; break; + case '\\': out << "\\\\"; break; + case '\b': out << "\\b"; break; + case '\f': out << "\\f"; break; + case '\t': out << "\\t"; break; + case '\r': out << "\\r"; break; + case '\n': out << "\\n"; break; default: if (c >= 32 && c < 127)