Fix content.cache.size overflow with QtWebEngine

While 64-bit values are allowed with QtWebKit/QNetworkDiskCache, QtWebEngine
only allows 32-bit values here. With the updated sip's strict overflow checking,
that means we get an exception when setting a too big value.
This commit is contained in:
Florian Bruhin 2017-11-21 14:07:49 +01:00
parent 75555fc244
commit 203b6c354f
3 changed files with 14 additions and 4 deletions

View File

@ -1455,6 +1455,7 @@ This setting is only available with the QtWebKit backend.
[[content.cache.size]] [[content.cache.size]]
=== content.cache.size === content.cache.size
Size (in bytes) of the HTTP network cache. Null to use the default value. Size (in bytes) of the HTTP network cache. Null to use the default value.
With QtWebEngine, the maximum supported value is 2147483647 (~2 GB).
Type: <<types,Int>> Type: <<types,Int>>

View File

@ -94,9 +94,10 @@ class DefaultProfileSetter(websettings.Base):
"""A setting set on the QWebEngineProfile.""" """A setting set on the QWebEngineProfile."""
def __init__(self, setter, default=websettings.UNSET): def __init__(self, setter, converter=None, default=websettings.UNSET):
super().__init__(default) super().__init__(default)
self._setter = setter self._setter = setter
self._converter = converter
def __repr__(self): def __repr__(self):
return utils.get_repr(self, setter=self._setter, constructor=True) return utils.get_repr(self, setter=self._setter, constructor=True)
@ -105,7 +106,11 @@ class DefaultProfileSetter(websettings.Base):
if settings is not None: if settings is not None:
raise ValueError("'settings' may not be set with " raise ValueError("'settings' may not be set with "
"DefaultProfileSetters!") "DefaultProfileSetters!")
setter = getattr(default_profile, self._setter) setter = getattr(default_profile, self._setter)
if self._converter is not None:
value = self._converter(value)
setter(value) setter(value)
@ -296,7 +301,9 @@ MAPPINGS = {
Attribute(QWebEngineSettings.LocalStorageEnabled), Attribute(QWebEngineSettings.LocalStorageEnabled),
'content.cache.size': 'content.cache.size':
# 0: automatically managed by QtWebEngine # 0: automatically managed by QtWebEngine
DefaultProfileSetter('setHttpCacheMaximumSize', default=0), DefaultProfileSetter('setHttpCacheMaximumSize', default=0,
converter=lambda val:
qtutils.check_overflow(val, 'int', fatal=False)),
'content.xss_auditing': 'content.xss_auditing':
Attribute(QWebEngineSettings.XSSAuditingEnabled), Attribute(QWebEngineSettings.XSSAuditingEnabled),
'content.default_encoding': 'content.default_encoding':

View File

@ -195,8 +195,10 @@ content.cache.size:
none_ok: true none_ok: true
minval: 0 minval: 0
maxval: maxint64 maxval: maxint64
desc: Size (in bytes) of the HTTP network cache. Null to use the default desc: >-
value. Size (in bytes) of the HTTP network cache. Null to use the default value.
With QtWebEngine, the maximum supported value is 2147483647 (~2 GB).
# Defaults from QWebSettings::QWebSettings() in # Defaults from QWebSettings::QWebSettings() in
# qtwebkit/Source/WebKit/qt/Api/qwebsettings.cpp # qtwebkit/Source/WebKit/qt/Api/qwebsettings.cpp