Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5185)

Unified Diff: chrome/browser/installable/installable_manager.cc

Issue 2248293002: Do not install WebAPKs with web manifests with invalid URL components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/installable/installable_manager.cc
diff --git a/chrome/browser/installable/installable_manager.cc b/chrome/browser/installable/installable_manager.cc
index 7b4362cc60fb3e779b8aecfcc085a48fbe08c061..2449d78f32e65985f5b62a61be0f74cb03e16468 100644
--- a/chrome/browser/installable/installable_manager.cc
+++ b/chrome/browser/installable/installable_manager.cc
@@ -50,6 +50,29 @@ bool DoesManifestContainRequiredIcon(const content::Manifest& manifest) {
return false;
}
+bool UrlHasUsernameOrPassword(const GURL& url) {
+ return url.has_username() || url.has_password();
+}
+
+// Returns whether any of the URLs in |manifest| has a username or password.
+bool DoesManifestHaveUrlWithUsernameOrPassword(
+ const content::Manifest& manifest) {
+ for (const content::Manifest::Icon& icon : manifest.icons) {
+ if (UrlHasUsernameOrPassword(icon.src))
+ return true;
+ }
+
+ for (const content::Manifest::RelatedApplication& related_application :
+ manifest.related_applications) {
+ if (UrlHasUsernameOrPassword(related_application.url)) {
+ return true;
+ }
+ }
+
+ return UrlHasUsernameOrPassword(manifest.start_url) ||
+ UrlHasUsernameOrPassword(manifest.scope);
+}
+
} // namespace
DEFINE_WEB_CONTENTS_USER_DATA_KEY(InstallableManager);
@@ -94,6 +117,7 @@ InstallableManager::InstallableManager(content::WebContents* web_contents)
InstallableManager::~InstallableManager() = default;
bool InstallableManager::IsManifestValidForWebApp(
+ const GURL& manifest_url,
const content::Manifest& manifest) {
if (manifest.IsEmpty()) {
installable_->error = MANIFEST_EMPTY;
@@ -111,6 +135,15 @@ bool InstallableManager::IsManifestValidForWebApp(
return false;
}
+ // WebAPK web manifests are stored on the Chrome WebAPK server. Classify
+ // web manifests with a user name or password as not-installable to avoid
+ // storing user names and passwords on the WebAPK server.
+ if (DoesManifestHaveUrlWithUsernameOrPassword(manifest) ||
dominickn 2016/08/17 22:54:43 I think this check should belong in WebAPK-specifi
pkotwicz 2016/08/18 01:11:41 The reason I put this code here is that there are
dominickn 2016/08/18 01:19:16 I think a separate WebApkManifestValidator is the
+ UrlHasUsernameOrPassword(manifest_url)) {
+ installable_->error = URL_USERNAME_AND_PASSWORD_NOT_SUPPORTED;
+ return false;
+ }
+
// TODO(dominickn,mlamouri): when Chrome supports "minimal-ui", it should be
// accepted. If we accept it today, it would fallback to "browser" and make
// this check moot. See https://crbug.com/604390.
@@ -321,7 +354,7 @@ void InstallableManager::CheckInstallable() {
DCHECK(!installable_->fetched);
DCHECK(!manifest().IsEmpty());
- if (IsManifestValidForWebApp(manifest())) {
+ if (IsManifestValidForWebApp(manifest_url(), manifest())) {
CheckServiceWorker();
} else {
installable_->installable = false;

Powered by Google App Engine
This is Rietveld 408576698