summaryrefslogtreecommitdiffstats
path: root/webkit/glue/media
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 21:34:15 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 21:34:15 +0000
commit2b68c89d7ebca6f0d85d5fb9d7ffe819d3c3a9a8 (patch)
tree64dee0837ebef42aae6f317aa84594009f0f9b82 /webkit/glue/media
parent6eb8bc81b0a56a299be050b0bf2c298496f2b7d9 (diff)
downloadchromium_src-2b68c89d7ebca6f0d85d5fb9d7ffe819d3c3a9a8.zip
chromium_src-2b68c89d7ebca6f0d85d5fb9d7ffe819d3c3a9a8.tar.gz
chromium_src-2b68c89d7ebca6f0d85d5fb9d7ffe819d3c3a9a8.tar.bz2
Reject invalid URLs in SimpleDataSource
Report an error when an invalid url is received. Checks also the scheme against, ftp, http, https and file. Review URL: http://codereview.chromium.org/131061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18754 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/media')
-rw-r--r--webkit/glue/media/simple_data_source.cc19
1 files changed, 18 insertions, 1 deletions
diff --git a/webkit/glue/media/simple_data_source.cc b/webkit/glue/media/simple_data_source.cc
index a9daf10..6207ddd 100644
--- a/webkit/glue/media/simple_data_source.cc
+++ b/webkit/glue/media/simple_data_source.cc
@@ -12,6 +12,22 @@
#include "webkit/glue/resource_loader_bridge.h"
#include "webkit/glue/webappcachecontext.h"
+namespace {
+
+const char kHttpScheme[] = "http";
+const char kHttpsScheme[] = "https";
+const char kFtpScheme[] = "ftp";
+
+// A helper method that accepts only HTTP, HTTPS and FILE protocol.
+bool IsSchemeSupported(const GURL& url) {
+ return url.SchemeIs(kHttpScheme) ||
+ url.SchemeIs(kHttpsScheme) ||
+ url.SchemeIs(kFtpScheme) ||
+ url.SchemeIsFile();
+}
+
+} // namespace
+
namespace webkit_glue {
SimpleDataSource::SimpleDataSource(MessageLoop* render_loop, int32 routing_id)
@@ -44,7 +60,8 @@ bool SimpleDataSource::Initialize(const std::string& url) {
// Validate the URL.
SetURL(GURL(url));
- if (!url_.is_valid()) {
+ if (!url_.is_valid() || !IsSchemeSupported(url_)) {
+ host_->Error(media::PIPELINE_ERROR_NETWORK);
return false;
}