electron/patches/chromium/dom_storage_limits.patch
Electron Bot b7d25ccb77 chore: bump chromium to 62327c655093c821aa0fcfc6db53f5fd943e08c7 (master) (#19792)
* chore: bump chromium in DEPS to f3bf493731e868e1f5f48e7e1adc02ea5eccfbbd

* chore: bump chromium in DEPS to 4db0c87d4aa6f27ffa0b5fc77d20e10047962484

* chore: bump chromium in DEPS to d933a504c264dc8fe85267f47aef3588531875b5

* chore: bump chromium in DEPS to 34afdb68980f581ae911b85b727bc17e126cf5f9

* update disable-redraw-lock.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1600387

* update desktop_media_list.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1729156

* update notification_provenance.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1742779

* update printing.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1646772

* update verbose_generate_bpad_syms.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1745986

* update patch metadata

* remove printing_compositor manifests

https://chromium-review.googlesource.com/c/chromium/src/+/1742734

* update for URLLoaderFactoryType enum

https://chromium-review.googlesource.com/c/chromium/src/+/1754716

* remove gin string16 converter

https://chromium-review.googlesource.com/c/chromium/src/+/1750093

* ClearCompositorFrame() has been removed

https://chromium-review.googlesource.com/c/chromium/src/+/1746301

* message_loop -> message_loop_current

https://chromium-review.googlesource.com/c/chromium/src/+/1738552

* include resource_response header

* pdf compositor no longer uses service manager

https://chromium-review.googlesource.com/c/chromium/src/+/1742734

* chore: bump chromium in DEPS to 00d5933101d8d8dc9546eadbe7ee1b41077e6db1

* pane focus fns aren't pure virtual anymore

https://chromium-review.googlesource.com/c/chromium/src/+/1708767

* fix: make std::hash value-non-const

broken by https://chromium-review.googlesource.com/c/chromium/src/+/1711202

* update swiftshader in zip_manifests

https://swiftshader-review.googlesource.com/c/SwiftShader/+/34911

* address feedback from @deepak1556

* don't enable kLegacyWindowsDWriteFontFallback

https://chromium-review.googlesource.com/c/chromium/src/+/1753006

* chore: bump chromium in DEPS to 84497314005e1968da06804f8fde539d9872310e

* update printing.patch

remove bottom diff owing to https://chromium-review.googlesource.com/c/chromium/src/+/1678182 and update for https://chromium-review.googlesource.com/c/chromium/src/+/1678182

* convert CookieChangeListener to new Mojo types

https://chromium-review.googlesource.com/c/chromium/src/+/1753371

* rename ui::ClipboardType -> ui::ClipboardBuffer

https://chromium-review.googlesource.com/c/chromium/src/+/1758730

* logging::LoggingSettings log_file -> log_file_path

https://chromium-review.googlesource.com/c/chromium/src/+/1699477

* roll DEPS to latest lkgr

* fix: override GetFontLookupTableCacheDir()

When Chromium goes to use its fallback font table creation code paths,
it creates the cache directory it uses by calling
GetFontLookupTableCacheDir() with a path that doesn't exist in Electron.
To ensure that a legitimate file path is created, we need to override it
with Electron's DIR_USER_DATA so it doesn't use chrome::DIR_USER_DATA.

* chore: bump chromium in DEPS to 6758a0879931bc4df630a80a36c82d7855ae3155

* update pthread_fchdir patch

https://chromium-review.googlesource.com/c/chromium/src/+/1759149

* update printing patch

* update cookie usage and fn signatures

https://chromium-review.googlesource.com/c/chromium/src/+/1758437

* chore: bump chromium in DEPS to bdaca97e1cc27fb977e56f30f74cdb906da9527e

* remove fix_make_std_hash_value-non-const.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1762335

* Convert enum to enum class for FocusManager::FocusChangeReason

https://chromium-review.googlesource.com/c/chromium/src/+/1767281

* roll DEPS to latest lkgr

* update dom_storage_limits.patch

https://chromium-review.googlesource.com/c/chromium/src/+/1767556
2019-08-23 18:14:23 -07:00

80 lines
4.2 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jacob Quant <jacobq@gmail.com>
Date: Tue, 6 Nov 2018 15:26:00 -0600
Subject: dom_storage_limits.patch
This patch circumvents the restriction on DOM storage objects,
namely `localStorage` and `sessionStorage`, which chromium otherwise
limits to approximately 10MiB.
That restriction originates from a recommendation
[in the Web Storage API specification](https://html.spec.whatwg.org/multipage/webstorage.html#disk-space-2)
that is motivated by the concern that hostile code could abuse this
feature to exhaust available storage capacity.
However, in the case of Electron, where the application developers
have control over all of the code being executed,
this safety precaution becomes a hindrance that does not add much value.
For example, if a malicious developer wanted to consume disk space
on a victim's machine they could do so via Node's native file system API.
By disabling this restriction or increasing the quota,
electron application developers can use `localStorage`
as their application's "back end", without being having
to limit the amount of data stored to 10MiB.
There may still be some benefit to keeping this restriction for applications that load remote content.
Although all remote data should be from a trusted source and transferred using
a secure channel, it is nevertheless advisable to include additional layers of protection
to mitigate risks associated with potential compromise of those other technologies.
With that in mind, an acceptable alternative to disabling the limit at compile-time
(as this patch currently does) would be to instead allow it to be disabled at run-time
for a given `BrowserWindow` via a `webPreferences` option,
similar to [`nodeIntegration`](https://electronjs.org/docs/tutorial/security#2-disable-nodejs-integration-for-remote-content).
diff --git a/content/common/dom_storage/dom_storage_types.h b/content/common/dom_storage/dom_storage_types.h
index e87afe5b8ee07f7038a7cc9c40832b6cd27884da..61c9a0dfff60f79c7b36ff5c7d741c06dca03ada 100644
--- a/content/common/dom_storage/dom_storage_types.h
+++ b/content/common/dom_storage/dom_storage_types.h
@@ -21,6 +21,7 @@ typedef std::map<base::string16, base::NullableString16> DOMStorageValuesMap;
// The quota for each storage area.
// This value is enforced in renderer processes and the browser process.
+// However, Electron's dom_storage_limits.patch removes the code that checks this limit.
const size_t kPerStorageAreaQuota = 10 * 1024 * 1024;
// In the browser process we allow some overage to
diff --git a/third_party/blink/renderer/modules/storage/cached_storage_area.cc b/third_party/blink/renderer/modules/storage/cached_storage_area.cc
index d91fdc2a7d52307126bc04d44167edadb8c743a8..630acfca527aaec44742d45e47ce29d7754e3385 100644
--- a/third_party/blink/renderer/modules/storage/cached_storage_area.cc
+++ b/third_party/blink/renderer/modules/storage/cached_storage_area.cc
@@ -107,11 +107,13 @@ bool CachedStorageArea::SetItem(const String& key,
Source* source) {
DCHECK(areas_->Contains(source));
+#if 0
// A quick check to reject obviously overbudget items to avoid priming the
// cache.
if ((key.length() + value.length()) * 2 >
mojom::blink::StorageArea::kPerStorageAreaQuota)
return false;
+#endif
EnsureLoaded();
String old_value;
diff --git a/third_party/blink/renderer/modules/storage/storage_area_map.cc b/third_party/blink/renderer/modules/storage/storage_area_map.cc
index 0da8a1e891edad60355792c40b7d15e90c1086e8..df71418d598d5bdf41e9a8a4340999d9d277aeef 100644
--- a/third_party/blink/renderer/modules/storage/storage_area_map.cc
+++ b/third_party/blink/renderer/modules/storage/storage_area_map.cc
@@ -113,10 +113,12 @@ bool StorageAreaMap::SetItemInternal(const String& key,
size_t new_quota_used = quota_used_ - old_item_size + new_item_size;
size_t new_memory_used = memory_used_ - old_item_memory + new_item_memory;
+#if 0
// Only check quota if the size is increasing, this allows
// shrinking changes to pre-existing files that are over budget.
if (check_quota && new_item_size > old_item_size && new_quota_used > quota_)
return false;
+#endif
keys_values_.Set(key, value);
ResetKeyIterator();