Skip to content

Commit

Permalink
restrict pickle protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
willforde committed Jun 28, 2020
1 parent a1f1708 commit 52c3e4a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion script.module.codequick/lib/codequick/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

if PY3:
from inspect import getfullargspec
PICKLE_PROTOCOL = 4
else:
# noinspection PyDeprecation
from inspect import getargspec as getfullargspec
PICKLE_PROTOCOL = 2

script_data = xbmcaddon.Addon("script.module.codequick")
addon_data = xbmcaddon.Addon()
Expand Down Expand Up @@ -402,7 +404,7 @@ def build_path(callback=None, args=None, query=None, **extra_query):

# Encode the query parameters using json
if query:
pickled = binascii.hexlify(pickle.dumps(query, protocol=pickle.HIGHEST_PROTOCOL))
pickled = binascii.hexlify(pickle.dumps(query, protocol=PICKLE_PROTOCOL))
query = "_pickle_={}".format(pickled.decode("ascii") if PY3 else pickled)

# Build kodi url with new path and query parameters
Expand Down
2 changes: 1 addition & 1 deletion tests/test_listing.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def test_related_py3(self):

self.assertEqual(label, "Related Videos")
self.assertEqual(command, "XBMC.Container.Update(plugin://script.module.codequick/tests/test_listing/"
"test_callback?_pickle_=8005951f000000000000007d948c075f746974"
"test_callback?_pickle_=8004951f000000000000007d948c075f746974"
"6c655f948c0e52656c6174656420566964656f7394732e)")

def test_related_with_params(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def test_build_path_new_args_py2(self):
def test_build_path_new_args_py3(self):
ret = support.build_path(self.callback, query={"testdata": "data"})
self.assertEqual("plugin://script.module.codequick/root?_pickle_="
"80059516000000000000007d948c08746573746461746194"
"80049516000000000000007d948c08746573746461746194"
"8c046461746194732e", ret)

@unittest.skipIf(PY3, "The pickled string is specific to python 2")
Expand All @@ -300,7 +300,7 @@ def test_build_path_extra_args_py3(self):
try:
ret = support.build_path(self.callback, testdata="data")
self.assertEqual("plugin://script.module.codequick/root?_pickle_="
"80059529000000000000007d94288c075f7469746c655f94"
"80049529000000000000007d94288c075f7469746c655f94"
"8c05766964656f948c087465737464617461948c046461746194752e", ret)
finally:
del support.dispatcher.params["_title_"]

0 comments on commit 52c3e4a

Please sign in to comment.