Bug 74443 - Media url with fragment may not load
Summary: Media url with fragment may not load
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Eric Carlson
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2011-12-13 13:15 PST by Eric Carlson
Modified: 2011-12-14 11:01 PST (History)
2 users (show)

See Also:


Attachments
Proposed patch. (6.12 KB, patch)
2011-12-13 14:23 PST, Eric Carlson
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Carlson 2011-12-13 13:15:51 PST
When MediaPlayer::load is not passed the MIME type for a url, it uses the extension to looks one up in the type cache. The code that extracts the extension searches for a '.' from the end of the url, without consideration for whether the url has a fragment or query.
Comment 1 Radar WebKit Bug Importer 2011-12-13 13:16:32 PST
<rdar://problem/10574697>
Comment 2 Eric Carlson 2011-12-13 14:23:55 PST
Created attachment 119084 [details]
Proposed patch.
Comment 3 WebKit Review Bot 2011-12-13 14:30:22 PST
Attachment 119084 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/medi..." exit_code: 1

Source/WebCore/platform/graphics/MediaPlayer.h:211:  The parameter name "url" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 7 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Darin Adler 2011-12-13 15:34:43 PST
Comment on attachment 119084 [details]
Proposed patch.

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

> Source/WebCore/platform/graphics/MediaPlayer.cpp:341
> +        if (protocolIs(urlString, "data"))

Would be better to call url.protocolIsData() since we have the URL.

> Source/WebCore/platform/graphics/MediaPlayer.cpp:347
> -            size_t pos = url.reverseFind('.');
> +            String lastPathComponent = url.lastPathComponent();
> +            size_t pos = lastPathComponent.reverseFind('.');
>              if (pos != notFound) {
> -                String extension = url.substring(pos + 1);
> +                String extension = lastPathComponent.substring(pos + 1);

Is this the only place in our code where we get the extension from a URL? If not, maybe they can share more code.

> Source/WebCore/platform/graphics/MediaPlayer.h:37
> +#include "KURL.h"

This include is not needed. All the header needs is a forward declaration of the KURL class.

>> Source/WebCore/platform/graphics/MediaPlayer.h:211
>> -    bool load(const String& url, const ContentType&);
>> +    bool load(const KURL& url, const ContentType&);
> 
> The parameter name "url" adds no information, so it should be removed.  [readability/parameter_name] [5]

I agree with the style bot.
Comment 5 Eric Carlson 2011-12-14 11:01:16 PST
http://trac.webkit.org/changeset/102800