Skip to content

Commit

Permalink
Avoid UnicodeEncodeError if a path contains invalid characters
Browse files Browse the repository at this point in the history
  • Loading branch information
hvelarde committed Jun 20, 2018
1 parent eb5713a commit f371424
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Changelog
1.4.2 (unreleased)
------------------

- Nothing changed yet.
- ``plone.app.transmogrifier.pathfixer`` now also converts a path into ``str`` and removes any invalid characters from it;
this avoids ``UnicodeEncodeError`` in many blueprint sections.
[hvelarde]


1.4.1 (2018-02-27)
Expand Down
3 changes: 2 additions & 1 deletion src/plone/app/transmogrifier/pathfixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def __iter__(self):
if prependstring:
path = '%s%s' % (prependstring, path)

item[pathkey] = path
# convert the path to str and remove invalid characters
item[pathkey] = path.encode('ascii', 'ignore')

yield item
2 changes: 2 additions & 0 deletions src/plone/app/transmogrifier/pathfixer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ root may have changed. This blueprint updates the old paths to match the new
structrue by removing or appending strings from the right side of the path
value.

It also converts the path to ``str`` and removes any invalid characters from it.

Blueprint name: ``plone.app.transmogrifier.pathfixer``

Option path-key: The key of the item under which the path to be manipulated can
Expand Down

0 comments on commit f371424

Please sign in to comment.