Bug 146079

Summary: [Content Extensions] Fail to parse invalid arrays
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: WebCore Misc.Assignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch benjamin: review+

Description Alex Christensen 2015-06-17 14:58:21 PDT
Right now there are some cases where we parse but ignore invalid arrays.  We should not succeed to parse these rules to prevent confusing developers.
Comment 1 Alex Christensen 2015-06-17 15:03:00 PDT
Created attachment 255039 [details]
Patch
Comment 2 Benjamin Poulain 2015-06-17 15:20:48 PDT
Comment on attachment 255039 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=255039&action=review

> Source/WebCore/contentextensions/ContentExtensionParser.cpp:138
> +    } else if (!resourceTypeValue.isUndefined())

else if (resourceTypeValue)?

> Source/WebCore/contentextensions/ContentExtensionParser.cpp:146
> +    } else if (!loadTypeValue.isUndefined())

ditto

> Source/WebCore/contentextensions/ContentExtensionParser.cpp:158
> +    } else if (!ifDomain.isUndefined())

ditto

> Source/WebCore/contentextensions/ContentExtensionParser.cpp:171
> +    } else if (!unlessDomain.isUndefined())

ditto

> Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:820
> +    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"resource-type\":\"document\"}}]",

Test passing null and undefined arguments? Maybe an array like object too?

> Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:851
> +    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"if-domain\":5}}]", ContentExtensions::ContentExtensionError::JSONInvalidDomainList);
> +    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"unless-domain\":5}}]", ContentExtensions::ContentExtensionError::JSONInvalidDomainList);
> +    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"if-domain\":5,\"unless-domain\":5}}]", ContentExtensions::ContentExtensionError::JSONInvalidDomainList);

ditto
Comment 3 Alex Christensen 2015-06-17 17:47:10 PDT
(In reply to comment #2)
> > Source/WebCore/contentextensions/ContentExtensionParser.cpp:138
> > +    } else if (!resourceTypeValue.isUndefined())
> 
> else if (resourceTypeValue)?
Nope.  That means something else.
> > Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:820
> > +    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"resource-type\":\"document\"}}]",
> 
> Test passing null and undefined arguments? Maybe an array like object too?
Done.
Comment 4 Alex Christensen 2015-06-17 17:52:50 PDT
http://trac.webkit.org/changeset/185683