Title: [102800] trunk
Revision
102800
Author
eric.carl...@apple.com
Date
2011-12-14 10:59:53 -0800 (Wed, 14 Dec 2011)

Log Message

Media url with fragment may not load
https://bugs.webkit.org/show_bug.cgi?id=74443

Reviewed by Darin Adler.

Source/WebCore: 

Test: media/media-extension-with-fragment.html

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::loadResource): Pass the KURL to MediaPlayer, let it extract a
    String when it needs it.

* platform/graphics/MediaPlayer.cpp:
(WebCore::MediaPlayer::load): Take a KURL, not a String. Look for the file extension in the 
    last path component so we don't examine fragments and/or queries.
* platform/graphics/MediaPlayer.h:

LayoutTests: 

* media/media-extension-with-fragment-expected.txt: Added.
* media/media-extension-with-fragment.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (102799 => 102800)


--- trunk/LayoutTests/ChangeLog	2011-12-14 18:52:29 UTC (rev 102799)
+++ trunk/LayoutTests/ChangeLog	2011-12-14 18:59:53 UTC (rev 102800)
@@ -1,3 +1,13 @@
+2011-12-14  Eric Carlson  <eric.carl...@apple.com>
+
+        Media url with fragment may not load
+        https://bugs.webkit.org/show_bug.cgi?id=74443
+
+        Reviewed by Darin Adler.
+
+        * media/media-extension-with-fragment-expected.txt: Added.
+        * media/media-extension-with-fragment.html: Added.
+
 2011-12-14  Kenneth Russell  <k...@google.com>
 
         Unreviewed Chromium test expectations update. Suppress another

Added: trunk/LayoutTests/media/media-extension-with-fragment-expected.txt (0 => 102800)


--- trunk/LayoutTests/media/media-extension-with-fragment-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/media-extension-with-fragment-expected.txt	2011-12-14 18:59:53 UTC (rev 102800)
@@ -0,0 +1,5 @@
+EVENT(loadeddata)
+MediaPlayer extracted extension from src url. OK
+
+END OF TEST
+

Added: trunk/LayoutTests/media/media-extension-with-fragment.html (0 => 102800)


--- trunk/LayoutTests/media/media-extension-with-fragment.html	                        (rev 0)
+++ trunk/LayoutTests/media/media-extension-with-fragment.html	2011-12-14 18:59:53 UTC (rev 102800)
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            function finish()
+            {
+                logResult(event.type == "loadeddata", "MediaPlayer extracted extension from src url.");
+                consoleWrite("");
+                endTest();
+            }
+
+
+            function start()
+            {
+                findMediaElement();
+                waitForEventAndEnd('loadeddata', finish);
+                waitForEvent('error', finish);
+                video.src = "" "content/test") + "#01.00.xyz";
+            }
+        </script>
+
+    </head>
+    <body _onload_="start()">
+
+        <video controls ></video>
+
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (102799 => 102800)


--- trunk/Source/WebCore/ChangeLog	2011-12-14 18:52:29 UTC (rev 102799)
+++ trunk/Source/WebCore/ChangeLog	2011-12-14 18:59:53 UTC (rev 102800)
@@ -1,3 +1,21 @@
+2011-12-14  Eric Carlson  <eric.carl...@apple.com>
+
+        Media url with fragment may not load
+        https://bugs.webkit.org/show_bug.cgi?id=74443
+
+        Reviewed by Darin Adler.
+
+        Test: media/media-extension-with-fragment.html
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::loadResource): Pass the KURL to MediaPlayer, let it extract a
+            String when it needs it.
+
+        * platform/graphics/MediaPlayer.cpp:
+        (WebCore::MediaPlayer::load): Take a KURL, not a String. Look for the file extension in the 
+            last path component so we don't examine fragments and/or queries.
+        * platform/graphics/MediaPlayer.h:
+
 2011-12-14  Jacky Jiang  <zhaji...@rim.com>
 
         [BlackBerry] Remove some duplicate entries in Source/WebCore/PlatformBlackBerry.cmake

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (102799 => 102800)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-12-14 18:52:29 UTC (rev 102799)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2011-12-14 18:59:53 UTC (rev 102800)
@@ -892,7 +892,7 @@
         m_muted = true;
     updateVolume();
 
-    if (!m_player->load(url.string(), contentType))
+    if (!m_player->load(url, contentType))
         mediaLoadingFailed(MediaPlayer::FormatError);
 
     // If there is no poster to display, allow the media engine to render video frames as soon as

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp (102799 => 102800)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2011-12-14 18:52:29 UTC (rev 102799)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp	2011-12-14 18:59:53 UTC (rev 102800)
@@ -331,19 +331,21 @@
     m_mediaPlayerClient = 0;
 }
 
-bool MediaPlayer::load(const String& url, const ContentType& contentType)
+bool MediaPlayer::load(const KURL& url, const ContentType& contentType)
 {
     String type = contentType.type().lower();
     String typeCodecs = contentType.parameter(codecs());
+    String urlString = url.string();
 
     // If the MIME type is missing or is not meaningful, try to figure it out from the URL.
     if (type.isEmpty() || type == applicationOctetStream() || type == textPlain()) {
-        if (protocolIs(url, "data"))
-            type = mimeTypeFromDataURL(url);
+        if (protocolIs(urlString, "data"))
+            type = mimeTypeFromDataURL(urlString);
         else {
-            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);
                 String mediaType = MIMETypeRegistry::getMediaMIMETypeForExtension(extension);
                 if (!mediaType.isEmpty())
                     type = mediaType;
@@ -351,7 +353,7 @@
         }
     }
 
-    m_url = url;
+    m_url = urlString;
     m_contentMIMEType = type;
     m_contentTypeCodecs = typeCodecs;
     loadWithNextMediaEngine(0);

Modified: trunk/Source/WebCore/platform/graphics/MediaPlayer.h (102799 => 102800)


--- trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2011-12-14 18:52:29 UTC (rev 102799)
+++ trunk/Source/WebCore/platform/graphics/MediaPlayer.h	2011-12-14 18:59:53 UTC (rev 102800)
@@ -34,6 +34,7 @@
 
 #include "Document.h"
 #include "IntRect.h"
+#include "KURL.h"
 #include <wtf/Forward.h>
 #include <wtf/HashSet.h>
 #include <wtf/OwnPtr.h>
@@ -207,7 +208,7 @@
     IntSize size() const { return m_size; }
     void setSize(const IntSize& size);
 
-    bool load(const String& url, const ContentType&);
+    bool load(const KURL& url, const ContentType&);
     void cancelLoad();
 
     bool visible() const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to