Bug 142872 - [Content Extensions] Test regular expression parse failures
Summary: [Content Extensions] Test regular expression parse failures
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-19 12:19 PDT by Alex Christensen
Modified: 2015-03-19 15:39 PDT (History)
1 user (show)

See Also:


Attachments
Patch (9.14 KB, patch)
2015-03-19 12:25 PDT, Alex Christensen
benjamin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alex Christensen 2015-03-19 12:19:17 PDT
I made things I think can never happen into assertions.  I had some questions, though.  They're in the first patch.
Comment 1 Alex Christensen 2015-03-19 12:25:02 PDT
Created attachment 249048 [details]
Patch
Comment 2 Benjamin Poulain 2015-03-19 14:35:47 PDT
Comment on attachment 249048 [details]
Patch

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

> Source/WebCore/contentextensions/URLFilterParser.cpp:481
> +        ASSERT(m_openGroups.isEmpty());
> +        ASSERT(m_subtreeStart != m_subtreeEnd);

Let's make them into ASSERT_WITH_MESSAGE to say why they should not happen.

> Source/WebCore/contentextensions/URLFilterParser.cpp:527
> -        if (!m_floatingTerm.isValid())
> -            fail(URLFilterParser::MisplacedQuantifier);
> +        ASSERT(m_floatingTerm.isValid());

Wouldn't this happen with greedy quantifiers?

> Source/WebCore/contentextensions/URLFilterParser.cpp:-727
> -    ASSERT(!pattern.isEmpty());
> -

Those are no longer excluded by the JSON parser?

> Source/WebCore/contentextensions/URLFilterParser.h:44
>      enum ParseStatus {

This thing is really weird.

> Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:355
> +    testPatternStatus("(?!)", ContentExtensions::URLFilterParser::ParseStatus::Group);
> +    testPatternStatus("(?=)", ContentExtensions::URLFilterParser::ParseStatus::Group);

Please also test that those two produce errors with a non-empty term inside.

> Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:370
> +    // I think these should all be YarrErrors, but they're not. Should we do something about this?

What the heck. I have no explanation.
Comment 3 Alex Christensen 2015-03-19 15:38:44 PDT
Comment on attachment 249048 [details]
Patch

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

>> Source/WebCore/contentextensions/URLFilterParser.cpp:527
>> +        ASSERT(m_floatingTerm.isValid());
> 
> Wouldn't this happen with greedy quantifiers?

I'm adding .*a and .*?a, but they do not hit this assert.

>> Source/WebCore/contentextensions/URLFilterParser.cpp:-727
>> -
> 
> Those are no longer excluded by the JSON parser?

I added a test case that tests an empty string.  They probably are excluded by the JSON parser, but the following if statement will catch them.
Comment 4 Alex Christensen 2015-03-19 15:39:04 PDT
https://trac.webkit.org/r181762