Skip to content

Commit

Permalink
Fix path2uid for py2.
Browse files Browse the repository at this point in the history
  • Loading branch information
tisto committed Oct 31, 2019
1 parent f77d8b9 commit fbbc17d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plone/restapi/deserializer/blocks.py
Expand Up @@ -11,10 +11,12 @@
from zope.interface import implementer
from zope.publisher.interfaces.browser import IBrowserRequest

import six


def path2uid(context, path):
# convert bytestring -> string; unrestrictedTraverse does not work with bytestrings
path = path.decode("utf-8")
if isinstance(path, six.binary_type):
path = path.decode("utf-8")

This comment has been minimized.

Copy link
@ale-rt

ale-rt Oct 31, 2019

Member

I think this should use safe_nativestring (or an equivalent) because path has to be a native str object, always, see zopefoundation/Zope#674, zopefoundation/Zope#715 and related

This comment has been minimized.

Copy link
@tisto

tisto Nov 2, 2019

Author Member

@ale-rt thanks for the hint!

obj = context.unrestrictedTraverse(path, None)
if obj is None:
return None, None
Expand Down

0 comments on commit fbbc17d

Please sign in to comment.