Title: [213470] trunk/Source/WebCore
- Revision
- 213470
- Author
- [email protected]
- Date
- 2017-03-06 14:56:43 -0800 (Mon, 06 Mar 2017)
Log Message
Refactor ContentExtensionParser
https://bugs.webkit.org/show_bug.cgi?id=169214
Reviewed by Brady Eidson.
No change in behavior, as verified by existing API tests.
This will make it easier to use getStringList for other things in coming patches.
* contentextensions/ContentExtensionParser.cpp:
(WebCore::ContentExtensions::getStringList):
(WebCore::ContentExtensions::getDomainList):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (213469 => 213470)
--- trunk/Source/WebCore/ChangeLog 2017-03-06 22:55:33 UTC (rev 213469)
+++ trunk/Source/WebCore/ChangeLog 2017-03-06 22:56:43 UTC (rev 213470)
@@ -1,5 +1,19 @@
2017-03-06 Alex Christensen <[email protected]>
+ Refactor ContentExtensionParser
+ https://bugs.webkit.org/show_bug.cgi?id=169214
+
+ Reviewed by Brady Eidson.
+
+ No change in behavior, as verified by existing API tests.
+ This will make it easier to use getStringList for other things in coming patches.
+
+ * contentextensions/ContentExtensionParser.cpp:
+ (WebCore::ContentExtensions::getStringList):
+ (WebCore::ContentExtensions::getDomainList):
+
+2017-03-06 Alex Christensen <[email protected]>
+
Fix URLs relative to file URLs with paths beginning with Windows drive letters
https://bugs.webkit.org/show_bug.cgi?id=169178
Modified: trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp (213469 => 213470)
--- trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp 2017-03-06 22:55:33 UTC (rev 213469)
+++ trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp 2017-03-06 22:56:43 UTC (rev 213470)
@@ -59,13 +59,13 @@
return true;
}
-static Expected<Vector<String>, std::error_code> getDomainList(ExecState& exec, const JSObject* arrayObject)
+static Expected<Vector<String>, std::error_code> getStringList(ExecState& exec, const JSObject* arrayObject, ContentExtensionError error)
{
VM& vm = exec.vm();
auto scope = DECLARE_THROW_SCOPE(vm);
if (!arrayObject || !isJSArray(arrayObject))
- return makeUnexpected(ContentExtensionError::JSONInvalidDomainList);
+ return makeUnexpected(error);
const JSArray* array = jsCast<const JSArray*>(arrayObject);
Vector<String> domains;
@@ -73,19 +73,29 @@
for (unsigned i = 0; i < length; ++i) {
const JSValue value = array->getIndex(&exec, i);
if (scope.exception() || !value.isString())
- return makeUnexpected(ContentExtensionError::JSONInvalidDomainList);
+ return makeUnexpected(error);
- // Domains should be punycode encoded lower case.
const String& domain = asString(value)->value(&exec);
if (domain.isEmpty())
- return makeUnexpected(ContentExtensionError::JSONInvalidDomainList);
- if (!containsOnlyASCIIWithNoUppercase(domain))
- return makeUnexpected(ContentExtensionError::JSONDomainNotLowerCaseASCII);
+ return makeUnexpected(error);
domains.append(domain);
}
return WTFMove(domains);
}
+static Expected<Vector<String>, std::error_code> getDomainList(ExecState& exec, const JSObject* arrayObject)
+{
+ auto strings = getStringList(exec, arrayObject, ContentExtensionError::JSONInvalidDomainList);
+ if (!strings.hasValue())
+ return strings;
+ for (auto& domain : strings.value()) {
+ // Domains should be punycode encoded lower case.
+ if (!containsOnlyASCIIWithNoUppercase(domain))
+ return makeUnexpected(ContentExtensionError::JSONDomainNotLowerCaseASCII);
+ }
+ return strings;
+}
+
static std::error_code getTypeFlags(ExecState& exec, const JSValue& typeValue, ResourceFlags& flags, uint16_t (*stringToType)(const String&))
{
VM& vm = exec.vm();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes