Hello community,
here is the log from the commit of package python-jsonpatch for
openSUSE:Factory checked in at 2020-08-06 17:32:10
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-jsonpatch (Old)
and /work/SRC/openSUSE:Factory/.python-jsonpatch.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-jsonpatch"
Thu Aug 6 17:32:10 2020 rev:21 rq:824356 version:1.26
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-jsonpatch/python-jsonpatch.changes
2020-03-08 22:21:35.075982952 +0100
+++
/work/SRC/openSUSE:Factory/.python-jsonpatch.new.3399/python-jsonpatch.changes
2020-08-06 17:32:45.849103426 +0200
@@ -1,0 +2,6 @@
+Tue Aug 4 16:19:12 UTC 2020 - Dirk Mueller <[email protected]>
+
+- update to 1.26:
+ * bugfixes (reject invalid json patches)
+
+-------------------------------------------------------------------
Old:
----
jsonpatch-1.25.tar.gz
New:
----
jsonpatch-1.26.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-jsonpatch.spec ++++++
--- /var/tmp/diff_new_pack.jeAiA6/_old 2020-08-06 17:32:46.585103598 +0200
+++ /var/tmp/diff_new_pack.jeAiA6/_new 2020-08-06 17:32:46.589103599 +0200
@@ -18,7 +18,7 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-jsonpatch
-Version: 1.25
+Version: 1.26
Release: 0
Summary: Python - JSON-Patches
License: BSD-3-Clause
++++++ jsonpatch-1.25.tar.gz -> jsonpatch-1.26.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonpatch-1.25/PKG-INFO new/jsonpatch-1.26/PKG-INFO
--- old/jsonpatch-1.25/PKG-INFO 2020-01-29 09:22:05.000000000 +0100
+++ new/jsonpatch-1.26/PKG-INFO 2020-06-22 14:57:28.000000000 +0200
@@ -1,17 +1,17 @@
Metadata-Version: 1.2
Name: jsonpatch
-Version: 1.25
+Version: 1.26
Summary: Apply JSON-Patches (RFC 6902)
Home-page: https://github.com/stefankoegl/python-json-patch
Author: Stefan Kögl
Author-email: [email protected]
License: Modified BSD License
Project-URL: Website, https://github.com/stefankoegl/python-json-patch
+Project-URL: Tests, https://travis-ci.org/stefankoegl/python-json-patch
Project-URL: Repository, https://github.com/stefankoegl/python-json-patch.git
+Project-URL: Test Coverage,
https://coveralls.io/r/stefankoegl/python-json-patch
Project-URL: Documentation, https://python-json-patch.readthedocs.org/
Project-URL: PyPI, https://pypi.org/pypi/jsonpatch
-Project-URL: Tests, https://travis-ci.org/stefankoegl/python-json-patch
-Project-URL: Test Coverage,
https://coveralls.io/r/stefankoegl/python-json-patch
Description: python-json-patch
=================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonpatch-1.25/jsonpatch.egg-info/PKG-INFO
new/jsonpatch-1.26/jsonpatch.egg-info/PKG-INFO
--- old/jsonpatch-1.25/jsonpatch.egg-info/PKG-INFO 2020-01-29
09:22:05.000000000 +0100
+++ new/jsonpatch-1.26/jsonpatch.egg-info/PKG-INFO 2020-06-22
14:57:28.000000000 +0200
@@ -1,17 +1,17 @@
Metadata-Version: 1.2
Name: jsonpatch
-Version: 1.25
+Version: 1.26
Summary: Apply JSON-Patches (RFC 6902)
Home-page: https://github.com/stefankoegl/python-json-patch
Author: Stefan Kögl
Author-email: [email protected]
License: Modified BSD License
Project-URL: Website, https://github.com/stefankoegl/python-json-patch
+Project-URL: Tests, https://travis-ci.org/stefankoegl/python-json-patch
Project-URL: Repository, https://github.com/stefankoegl/python-json-patch.git
+Project-URL: Test Coverage,
https://coveralls.io/r/stefankoegl/python-json-patch
Project-URL: Documentation, https://python-json-patch.readthedocs.org/
Project-URL: PyPI, https://pypi.org/pypi/jsonpatch
-Project-URL: Tests, https://travis-ci.org/stefankoegl/python-json-patch
-Project-URL: Test Coverage,
https://coveralls.io/r/stefankoegl/python-json-patch
Description: python-json-patch
=================
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonpatch-1.25/jsonpatch.py
new/jsonpatch-1.26/jsonpatch.py
--- old/jsonpatch-1.25/jsonpatch.py 2020-01-29 09:18:14.000000000 +0100
+++ new/jsonpatch-1.26/jsonpatch.py 2020-06-22 14:57:11.000000000 +0200
@@ -56,7 +56,7 @@
# Will be parsed by setup.py to determine package metadata
__author__ = 'Stefan Kögl <[email protected]>'
-__version__ = '1.25'
+__version__ = '1.26'
__website__ = 'https://github.com/stefankoegl/python-json-patch'
__license__ = 'Modified BSD License'
@@ -76,9 +76,9 @@
class JsonPatchConflict(JsonPatchException):
"""Raised if patch could not be applied due to conflict situation such as:
- - attempt to add object key then it already exists;
+ - attempt to add object key when it already exists;
- attempt to operate with nonexistence object key;
- - attempt to insert value to array at position beyond of it size;
+ - attempt to insert value to array at position beyond its size;
- etc.
"""
@@ -144,7 +144,7 @@
def make_patch(src, dst):
- """Generates patch by comparing of two document objects. Actually is
+ """Generates patch by comparing two document objects. Actually is
a proxy to :meth:`JsonPatch.from_diff` method.
:param src: Data source document object.
@@ -181,8 +181,8 @@
>>> result == expected
True
- JsonPatch object is iterable, so you could easily access to each patch
- statement in loop:
+ JsonPatch object is iterable, so you can easily access each patch
+ statement in a loop:
>>> lpatch = list(patch)
>>> expected = {'op': 'add', 'path': '/foo', 'value': 'bar'}
@@ -259,7 +259,7 @@
@classmethod
def from_diff(cls, src, dst, optimization=True):
- """Creates JsonPatch instance based on comparing of two document
+ """Creates JsonPatch instance based on comparison of two document
objects. Json patch would be created for `src` argument against `dst`
one.
@@ -293,13 +293,13 @@
return tuple(map(self._get_operation, self.patch))
def apply(self, obj, in_place=False):
- """Applies the patch to given object.
+ """Applies the patch to a given object.
:param obj: Document object.
:type obj: dict
- :param in_place: Tweaks way how patch would be applied - directly to
- specified `obj` or to his copy.
+ :param in_place: Tweaks the way how patch would be applied - directly
to
+ specified `obj` or to its copy.
:type in_place: bool
:return: Modified `obj`.
@@ -334,18 +334,24 @@
def __init__(self, operation):
+ if not operation.__contains__('path'):
+ raise InvalidJsonPatch("Operation must have a 'path' member")
+
if isinstance(operation['path'], JsonPointer):
self.location = operation['path'].path
self.pointer = operation['path']
else:
self.location = operation['path']
- self.pointer = JsonPointer(self.location)
+ try:
+ self.pointer = JsonPointer(self.location)
+ except TypeError as ex:
+ raise InvalidJsonPatch("Invalid 'path'")
self.operation = operation
def apply(self, obj):
- """Abstract method that applies patch operation to specified object."""
- raise NotImplementedError('should implement patch operation.')
+ """Abstract method that applies a patch operation to the specified
object."""
+ raise NotImplementedError('should implement the patch operation.')
def __hash__(self):
return hash(frozenset(self.operation.items()))
@@ -384,7 +390,7 @@
try:
del subobj[part]
except (KeyError, IndexError) as ex:
- msg = "can't remove non-existent object '{0}'".format(part)
+ msg = "can't remove a non-existent object '{0}'".format(part)
raise JsonPatchConflict(msg)
return obj
@@ -459,7 +465,7 @@
class ReplaceOperation(PatchOperation):
- """Replaces an object property or an array element by new value."""
+ """Replaces an object property or an array element by a new value."""
def apply(self, obj):
try:
@@ -473,13 +479,16 @@
if part is None:
return value
+ if part == "-":
+ raise InvalidJsonPatch("'path' with '-' can't be applied to
'replace' operation")
+
if isinstance(subobj, MutableSequence):
if part >= len(subobj) or part < 0:
raise JsonPatchConflict("can't replace outside of list")
elif isinstance(subobj, MutableMapping):
if part not in subobj:
- msg = "can't replace non-existent object '{0}'".format(part)
+ msg = "can't replace a non-existent object '{0}'".format(part)
raise JsonPatchConflict(msg)
else:
if part is None:
@@ -498,7 +507,7 @@
class MoveOperation(PatchOperation):
- """Moves an object property or an array element to new location."""
+ """Moves an object property or an array element to a new location."""
def apply(self, obj):
try:
@@ -522,7 +531,7 @@
if isinstance(subobj, MutableMapping) and \
self.pointer.contains(from_ptr):
- raise JsonPatchConflict('Cannot move values into its own children')
+ raise JsonPatchConflict('Cannot move values into their own
children')
obj = RemoveOperation({
'op': 'remove',
@@ -826,7 +835,7 @@
self._compare_lists(_path_join(path, key), src, dst)
# To ensure we catch changes to JSON, we can't rely on a simple
- # src == dst, or it would not recognize the difference between
+ # src == dst, because it would not recognize the difference between
# 1 and True, among other things. Using json.dumps is the most
# fool-proof way to ensure we catch type changes that matter to JSON
# and ignore those that don't. The performance of this could be
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/jsonpatch-1.25/tests.py new/jsonpatch-1.26/tests.py
--- old/jsonpatch-1.25/tests.py 2020-01-29 09:16:32.000000000 +0100
+++ new/jsonpatch-1.26/tests.py 2020-06-22 14:57:11.000000000 +0200
@@ -219,6 +219,17 @@
])
self.assertEqual(res['foo'], [1, 2, 3, 4])
+ def test_add_missing_path(self):
+ obj = {'bar': 'qux'}
+ self.assertRaises(jsonpatch.InvalidJsonPatch,
+ jsonpatch.apply_patch,
+ obj, [{'op': 'test', 'value': 'bar'}])
+
+ def test_path_with_null_value(self):
+ obj = {'bar': 'qux'}
+ self.assertRaises(jsonpatch.InvalidJsonPatch,
+ jsonpatch.apply_patch,
+ obj, '[{"op": "add", "path": null, "value": "bar"}]')
class EqualityTestCase(unittest.TestCase):