1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

WebBrowserComponent: Fix passing on escaped string sequences to native function completions

This commit is contained in:
attila 2024-04-24 19:33:38 +02:00
parent 552b39301e
commit d9095fccb2

View file

@ -414,8 +414,19 @@ public:
void emitEvent (const Identifier& eventId, const var& object)
{
// The object parameter is serialised into a string and used as a parameter to a Javascript
// function call. During this JS parameter substitution, control character escape sequences
// would be interpreted as the control characters themselves. So we need to escape anything
// that was escaped.
//
// We also need to escape the ' character since we use this to delimit the parameter string
// to emitByBackend.
const auto objectAsString = JSON::toString (object, true);
const auto escaped = objectAsString.replace ("\\", "\\\\").replace ("'", "\\'");
evaluateJavascript ("window.__JUCE__.backend.emitByBackend(" + eventId.toString().quoted() + ", "
+ JSON::toString (object, true).quoted ('\'') + ");", evaluationHandler);
+ escaped.quoted ('\'')
+ ");", evaluationHandler);
}
void goToURL (const String& url, const StringArray* headers, const MemoryBlock* postData)