Bug 162864 - URLParser: empty relative URLs should not copy fragment from the base URL
Summary: URLParser: empty relative URLs should not copy fragment from the base URL
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Alex Christensen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-03 08:21 PDT by Alex Christensen
Modified: 2016-10-03 10:31 PDT (History)
0 users

See Also:


Attachments
Patch (9.54 KB, patch)
2016-10-03 08:24 PDT, Alex Christensen
no flags Details | Formatted Diff | Diff
Patch (9.08 KB, patch)
2016-10-03 09:04 PDT, Alex Christensen
cdumez: 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 2016-10-03 08:21:03 PDT
URLParser: empty relative URLs should not copy fragment from the base URL
Comment 1 Alex Christensen 2016-10-03 08:24:15 PDT
Created attachment 290484 [details]
Patch
Comment 2 Alex Christensen 2016-10-03 09:04:38 PDT
Created attachment 290486 [details]
Patch
Comment 3 Chris Dumez 2016-10-03 10:13:41 PDT
Comment on attachment 290486 [details]
Patch

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

> Source/WebCore/platform/URL.cpp:1115
> +        m_string = m_string.substring(0, m_queryEnd);

Seems like this should be m_string.left(m_queryEnd) as in the original code.

> Source/WebCore/platform/URLParser.cpp:770
> +        RELEASE_ASSERT(length <= string.length());

This assertion is already present at the beginning of the function. Should probably be dropped here.

> Source/WebCore/platform/URLParser.cpp:1082
> +            && m_url.m_string == base.m_string.substring(0, base.m_queryEnd)));

substring() -> left()
This allocates the String unnecessarily. I understand this is an assertion but it'd still be nice to use a StringView.
Comment 4 Alex Christensen 2016-10-03 10:31:04 PDT
I don't particularly like the name "left" but done.
https://trac.webkit.org/changeset/206735