Bug 161443

Summary: URLParser should handle . and .. in URL paths
Product: WebKit Reporter: Alex Christensen <achristensen>
Component: New BugsAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: commit-queue, saam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch beidson: review+

Description Alex Christensen 2016-08-31 11:23:31 PDT
URLParser should handle . and .. in URL paths
Comment 1 Alex Christensen 2016-08-31 11:23:58 PDT
Created attachment 287522 [details]
Patch
Comment 2 WebKit Commit Bot 2016-08-31 11:40:48 PDT
Attachment 287522 [details] did not pass style-queue:


ERROR: Source/WebCore/ChangeLog:8:  You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible.  [changelog/nonewtests] [5]
Total errors found: 1 in 4 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Alex Christensen 2016-08-31 14:27:31 PDT
Created attachment 287543 [details]
Patch
Comment 4 Alex Christensen 2016-09-01 11:56:34 PDT
Created attachment 287649 [details]
Patch
Comment 5 Brady Eidson 2016-09-01 12:07:29 PDT
Comment on attachment 287543 [details]
Patch

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

> Source/WebCore/platform/URLParser.cpp:152
> +static bool isSingleDotPathSegment(StringView::CodePoints::Iterator c, const StringView::CodePoints::Iterator& end)
> +{
> +    if (c == end)
> +        return false;
> +    if (*c == '.') {
> +        ++c;
> +        return c == end || *c == '/' || *c == '\\' || *c == '?' || *c == '#';
> +    }
> +    if (*c != '%')
> +        return false;
> +    ++c;
> +    if (c == end || *c != '2')
> +        return false;
> +    ++c;
> +    if (c == end)
> +        return false;
> +    if (*c == 'e' || *c == 'E') {
> +        ++c;
> +        return c == end || *c == '/' || *c == '\\' || *c == '?' || *c == '#';
> +    }
> +    return false;
> +}

"2E" is a magic constant that should be more obvious.

static const char dotASCIICode = "2E";
?

> Source/WebCore/platform/URLParser.cpp:171
> +    if (c == end || *c != '2')
> +        return false;
> +    ++c;
> +    if (c == end)
> +        return false;
> +    if (*c == 'e' || *c == 'E') {
> +        ++c;

Same magic constant comment.

> Source/WebCore/platform/URLParser.cpp:194
> +        ASSERT(*c == '%');
> +        ++c;
> +        ASSERT(*c == '2');
> +        ++c;
> +        ASSERT(*c == 'e' || *c == 'E');
> +        ++c;

Same comment you guessed it.

> Source/WebCore/platform/URLParser.cpp:215
> +        ASSERT(*c == '2');
> +        ++c;
> +        ASSERT(*c == 'e' || *c == 'E');
> +        ++c;
> +    }

You guessed it.
Comment 6 Alex Christensen 2016-09-01 12:47:20 PDT
Created attachment 287657 [details]
Patch
Comment 7 Alex Christensen 2016-09-01 13:35:40 PDT
http://trac.webkit.org/changeset/205312