summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pickle.py2
-rw-r--r--Lib/test/pickletester.py8
2 files changed, 9 insertions, 1 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index e81a379..161c2e9 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -951,7 +951,7 @@ class _Unpickler:
rep = orig[:-1]
for q in (b'"', b"'"): # double or single quote
if rep.startswith(q):
- if not rep.endswith(q):
+ if len(rep) < 2 or not rep.endswith(q):
raise ValueError("insecure string pickle")
rep = rep[len(q):-len(q)]
break
diff --git a/Lib/test/pickletester.py b/Lib/test/pickletester.py
index 5d12375..a72ab37 100644
--- a/Lib/test/pickletester.py
+++ b/Lib/test/pickletester.py
@@ -609,6 +609,14 @@ class AbstractPickleTests(unittest.TestCase):
b"'abc\"", # open quote and close quote don't match
b"'abc' ?", # junk after close quote
b"'\\'", # trailing backslash
+ # Variations on issue #17710
+ b"'",
+ b'"',
+ b"' ",
+ b"' ",
+ b"' ",
+ b"' ",
+ b'" ',
# some tests of the quoting rules
## b"'abc\"\''",
## b"'\\\\a\'\'\'\\\'\\\\\''",