- Revision
- 260887
- Author
- [email protected]
- Date
- 2020-04-29 01:23:06 -0700 (Wed, 29 Apr 2020)
Log Message
Web Inspector: Uncaught Exception: SyntaxError: Unexpected identifier 'E'. Expected either a closing ']' or a ',' following an array element.
https://bugs.webkit.org/show_bug.cgi?id=211163
Reviewed by Joseph Pecoraro.
Source/WebKit:
* WebProcess/Inspector/WebInspectorUI.cpp:
(WebKit::WebInspectorUI::updateFindString):
* WebProcess/Inspector/RemoteWebInspectorUI.cpp:
(WebKit::RemoteWebInspectorUI::updateFindString):
Use the newly exposed `JSON::Value::escapeString` to ensure that the `findString` will not
throw a _javascript_ exception when placed in the `InspectorFrontendAPI` call.
Source/WTF:
* wtf/JSONValues.h:
* wtf/JSONValues.cpp:
(WTF::JSONImpl::appendDoubleQuotedString):
(WTF::JSONImpl::Value::escapeString): Added.
Pull out and expose the logic for escaping strings so it can be used elsewhere.
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (260886 => 260887)
--- trunk/Source/WTF/ChangeLog 2020-04-29 08:14:06 UTC (rev 260886)
+++ trunk/Source/WTF/ChangeLog 2020-04-29 08:23:06 UTC (rev 260887)
@@ -1,3 +1,16 @@
+2020-04-29 Devin Rousso <[email protected]>
+
+ Web Inspector: Uncaught Exception: SyntaxError: Unexpected identifier 'E'. Expected either a closing ']' or a ',' following an array element.
+ https://bugs.webkit.org/show_bug.cgi?id=211163
+
+ Reviewed by Joseph Pecoraro.
+
+ * wtf/JSONValues.h:
+ * wtf/JSONValues.cpp:
+ (WTF::JSONImpl::appendDoubleQuotedString):
+ (WTF::JSONImpl::Value::escapeString): Added.
+ Pull out and expose the logic for escaping strings so it can be used elsewhere.
+
2020-04-29 Saam Barati <[email protected]>
U_STRING_NOT_TERMINATED_WARNING ICU must be handled when using the output buffer as a C string
Modified: trunk/Source/WTF/wtf/JSONValues.cpp (260886 => 260887)
--- trunk/Source/WTF/wtf/JSONValues.cpp 2020-04-29 08:14:06 UTC (rev 260886)
+++ trunk/Source/WTF/wtf/JSONValues.cpp 2020-04-29 08:23:06 UTC (rev 260887)
@@ -453,42 +453,7 @@
inline void appendDoubleQuotedString(StringBuilder& builder, StringView string)
{
builder.append('"');
- for (UChar codeUnit : string.codeUnits()) {
- switch (codeUnit) {
- case '\b':
- builder.appendLiteral("\\b");
- continue;
- case '\f':
- builder.appendLiteral("\\f");
- continue;
- case '\n':
- builder.appendLiteral("\\n");
- continue;
- case '\r':
- builder.appendLiteral("\\r");
- continue;
- case '\t':
- builder.appendLiteral("\\t");
- continue;
- case '\\':
- builder.appendLiteral("\\\\");
- continue;
- case '"':
- builder.appendLiteral("\\\"");
- continue;
- }
- // We escape < and > to prevent script execution.
- if (codeUnit >= 32 && codeUnit < 127 && codeUnit != '<' && codeUnit != '>') {
- builder.append(codeUnit);
- continue;
- }
- // We could encode characters >= 127 as UTF-8 instead of \u escape sequences.
- // We could handle surrogates here if callers wanted that; for now we just
- // write them out as a \u sequence, so a surrogate pair appears as two of them.
- builder.append("\\u",
- upperNibbleToASCIIHexDigit(codeUnit >> 8), lowerNibbleToASCIIHexDigit(codeUnit >> 8),
- upperNibbleToASCIIHexDigit(codeUnit), lowerNibbleToASCIIHexDigit(codeUnit));
- }
+ Value::escapeString(builder, string);
builder.append('"');
}
@@ -560,6 +525,46 @@
return true;
}
+void Value::escapeString(StringBuilder& builder, StringView string)
+{
+ for (UChar codeUnit : string.codeUnits()) {
+ switch (codeUnit) {
+ case '\b':
+ builder.appendLiteral("\\b");
+ continue;
+ case '\f':
+ builder.appendLiteral("\\f");
+ continue;
+ case '\n':
+ builder.appendLiteral("\\n");
+ continue;
+ case '\r':
+ builder.appendLiteral("\\r");
+ continue;
+ case '\t':
+ builder.appendLiteral("\\t");
+ continue;
+ case '\\':
+ builder.appendLiteral("\\\\");
+ continue;
+ case '"':
+ builder.appendLiteral("\\\"");
+ continue;
+ }
+ // We escape < and > to prevent script execution.
+ if (codeUnit >= 32 && codeUnit < 127 && codeUnit != '<' && codeUnit != '>') {
+ builder.append(codeUnit);
+ continue;
+ }
+ // We could encode characters >= 127 as UTF-8 instead of \u escape sequences.
+ // We could handle surrogates here if callers wanted that; for now we just
+ // write them out as a \u sequence, so a surrogate pair appears as two of them.
+ builder.append("\\u",
+ upperNibbleToASCIIHexDigit(codeUnit >> 8), lowerNibbleToASCIIHexDigit(codeUnit >> 8),
+ upperNibbleToASCIIHexDigit(codeUnit), lowerNibbleToASCIIHexDigit(codeUnit));
+ }
+}
+
String Value::toJSONString() const
{
StringBuilder result;
Modified: trunk/Source/WTF/wtf/JSONValues.h (260886 => 260887)
--- trunk/Source/WTF/wtf/JSONValues.h 2020-04-29 08:14:06 UTC (rev 260886)
+++ trunk/Source/WTF/wtf/JSONValues.h 2020-04-29 08:23:06 UTC (rev 260887)
@@ -108,6 +108,7 @@
virtual bool asArray(RefPtr<Array>&);
static bool parseJSON(const String& jsonInput, RefPtr<Value>& output);
+ static void escapeString(StringBuilder&, StringView);
String toJSONString() const;
virtual void writeJSON(StringBuilder& output) const;
Modified: trunk/Source/WebKit/ChangeLog (260886 => 260887)
--- trunk/Source/WebKit/ChangeLog 2020-04-29 08:14:06 UTC (rev 260886)
+++ trunk/Source/WebKit/ChangeLog 2020-04-29 08:23:06 UTC (rev 260887)
@@ -1,3 +1,17 @@
+2020-04-29 Devin Rousso <[email protected]>
+
+ Web Inspector: Uncaught Exception: SyntaxError: Unexpected identifier 'E'. Expected either a closing ']' or a ',' following an array element.
+ https://bugs.webkit.org/show_bug.cgi?id=211163
+
+ Reviewed by Joseph Pecoraro.
+
+ * WebProcess/Inspector/WebInspectorUI.cpp:
+ (WebKit::WebInspectorUI::updateFindString):
+ * WebProcess/Inspector/RemoteWebInspectorUI.cpp:
+ (WebKit::RemoteWebInspectorUI::updateFindString):
+ Use the newly exposed `JSON::Value::escapeString` to ensure that the `findString` will not
+ throw a _javascript_ exception when placed in the `InspectorFrontendAPI` call.
+
2020-04-28 Carlos Garcia Campos <[email protected]>
[GTK4] Add support for key events
Modified: trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp (260886 => 260887)
--- trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp 2020-04-29 08:14:06 UTC (rev 260886)
+++ trunk/Source/WebKit/WebProcess/Inspector/RemoteWebInspectorUI.cpp 2020-04-29 08:23:06 UTC (rev 260887)
@@ -69,7 +69,9 @@
void RemoteWebInspectorUI::updateFindString(const String& findString)
{
- m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, findString);
+ StringBuilder builder;
+ JSON::Value::escapeString(builder, findString);
+ m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, builder.toString());
}
void RemoteWebInspectorUI::didSave(const String& url)
Modified: trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp (260886 => 260887)
--- trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp 2020-04-29 08:14:06 UTC (rev 260886)
+++ trunk/Source/WebKit/WebProcess/Inspector/WebInspectorUI.cpp 2020-04-29 08:23:06 UTC (rev 260887)
@@ -271,7 +271,9 @@
void WebInspectorUI::updateFindString(const String& findString)
{
- m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, findString);
+ StringBuilder builder;
+ JSON::Value::escapeString(builder, findString);
+ m_frontendAPIDispatcher.dispatchCommand("updateFindString"_s, builder.toString());
}
void WebInspectorUI::changeAttachedWindowHeight(unsigned height)