Index: content/browser/browser_plugin/browser_plugin_embedder.cc |
diff --git a/content/browser/browser_plugin/browser_plugin_embedder.cc b/content/browser/browser_plugin/browser_plugin_embedder.cc |
index 1f4b64ba3657a4fd283fb7fd1e5c8f125e467336..c79ae8e776c763e4f85bede291b7618b313b342d 100644 |
--- a/content/browser/browser_plugin/browser_plugin_embedder.cc |
+++ b/content/browser/browser_plugin/browser_plugin_embedder.cc |
@@ -15,7 +15,9 @@ |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
#include "content/public/browser/notification_types.h" |
+#include "content/public/common/result_codes.h" |
#include "content/public/common/url_constants.h" |
+#include "net/base/escape.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
#include "ui/gfx/size.h" |
@@ -80,11 +82,35 @@ void BrowserPluginEmbedder::CreateGuest( |
BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
CHECK(!guest); |
+ // Validate that the partition id coming from the renderer is valid UTF-8, |
+ // since we depend on this in other parts of the code, such as FilePath |
+ // creation. If the validation fails, treat it as a bad message and kill the |
+ // process. |
awong
2012/11/07 18:14:30
process -> renderer process
nasko
2012/11/07 18:48:05
Done.
|
+ if (!IsStringUTF8(params.storage_partition_id)) { |
+ base::KillProcess(render_view_host->GetProcess()->GetHandle(), |
Charlie Reis
2012/11/07 18:38:36
Please add this line before the kill:
content::Rec
nasko
2012/11/07 18:48:05
Done.
|
+ content::RESULT_CODE_KILLED_BAD_MESSAGE, false); |
+ return; |
+ } |
+ |
const std::string& host = |
render_view_host->GetSiteInstance()->GetSiteURL().host(); |
+ std::string url_encoded_partition = net::EscapeQueryParamValue( |
+ params.storage_partition_id, false); |
+ |
+ // The SiteInstance of a given webview tag is based on the fact that it's a |
+ // guest process in addition to which platform application the tag belongs to |
+ // and what storage partition is in use, rather than the URL that the tag is |
+ // being navigated to. |
+ GURL guest_site( |
+ base::StringPrintf("%s://%s/%s?%s", chrome::kGuestScheme, |
+ host.c_str(), params.persist_storage ? "persist" : "", |
+ url_encoded_partition.c_str())); |
+ SiteInstance* guest_site_instance = SiteInstance::CreateForURL( |
+ web_contents()->GetBrowserContext(), guest_site); |
+ |
guest_web_contents = WebContentsImpl::CreateGuest( |
web_contents()->GetBrowserContext(), |
- host, |
+ guest_site_instance, |
instance_id, |
params); |