summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2020-01-05 19:26:14 +0100
committerFlorian Bruhin <me@the-compiler.org>2020-01-05 19:26:14 +0100
commit73e2dd73573738bfea829c7685a4a4dda6bd6a57 (patch)
tree23e8ed03d3fd5b1c0e32aa8ea09d1c2d66c8cd0a
parentee4f1c4036a6c7f308986e449f89e8eaee603ecb (diff)
downloadqutebrowser-73e2dd73573738bfea829c7685a4a4dda6bd6a57.tar.gz
qutebrowser-73e2dd73573738bfea829c7685a4a4dda6bd6a57.zip
Handle yet another "too complex" sqlite error
-rw-r--r--doc/changelog.asciidoc2
-rw-r--r--qutebrowser/misc/sql.py4
-rw-r--r--tests/unit/completion/test_histcategory.py18
3 files changed, 20 insertions, 4 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 500ca4285..5f9d27351 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -109,6 +109,8 @@ Fixed
- The tab hover text now shows ampersands (&) correctly.
- With QtWebEngine and Qt >= 5.11, the inspector now shows its icons correctly
even if loading of images is disabled via the `content.images` setting.
+- Crash when entering a very long string (over 50k characters) in the
+ completion.
- Various improvements for URL/searchengine detection:
- Strings with a dot but with characters not allowed in a URL (e.g. an
underscore) are now not treated as URL anymore.
diff --git a/qutebrowser/misc/sql.py b/qutebrowser/misc/sql.py
index 4b12d8134..39208819d 100644
--- a/qutebrowser/misc/sql.py
+++ b/qutebrowser/misc/sql.py
@@ -119,9 +119,9 @@ def raise_sqlite_error(msg, error):
# If the query we built was too long
too_long_err = (
error_code == SqliteErrorCode.ERROR and
- driver_text == "Unable to execute statement" and
(database_text.startswith("Expression tree is too large") or
- database_text == "too many SQL variables"))
+ database_text in ["too many SQL variables",
+ "LIKE or GLOB pattern too complex"]))
if error_code in known_errors or qtbug_70506 or too_long_err:
raise KnownError(msg, error)
diff --git a/tests/unit/completion/test_histcategory.py b/tests/unit/completion/test_histcategory.py
index 9a5cd7edf..b9d20cae6 100644
--- a/tests/unit/completion/test_histcategory.py
+++ b/tests/unit/completion/test_histcategory.py
@@ -22,6 +22,8 @@
import datetime
import logging
+import hypothesis
+from hypothesis import strategies
import pytest
from qutebrowser.misc import sql
@@ -135,15 +137,27 @@ def test_set_pattern_repeated(model_validator, hist):
])
-def test_set_pattern_long(hist, message_mock, caplog):
+@pytest.mark.parametrize('pattern', [
+ ' '.join(map(str, range(10000))),
+ 'x' * 50000,
+], ids=['numbers', 'characters'])
+def test_set_pattern_long(hist, message_mock, caplog, pattern):
hist.insert({'url': 'example.com/foo', 'title': 'title1', 'last_atime': 1})
cat = histcategory.HistoryCategory()
with caplog.at_level(logging.ERROR):
- cat.set_pattern(" ".join(map(str, range(10000))))
+ cat.set_pattern(pattern)
msg = message_mock.getmsg(usertypes.MessageLevel.error)
assert msg.text.startswith("Error with SQL query:")
+@hypothesis.given(pat=strategies.text())
+def test_set_pattern_hypothesis(hist, pat, caplog):
+ hist.insert({'url': 'example.com/foo', 'title': 'title1', 'last_atime': 1})
+ cat = histcategory.HistoryCategory()
+ with caplog.at_level(logging.ERROR):
+ cat.set_pattern(pat)
+
+
@pytest.mark.parametrize('max_items, before, after', [
(-1, [
('a', 'a', '2017-04-16'),