diff --git a/HISTORY.rst b/HISTORY.rst index 2dae27dc86..11080485be 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -34,6 +34,9 @@ (@mbru) for the report and debug information. GitLab issue #557. * Add the MIMETYPE_FILE_READ_SIZE setting to limit the number of bytes read to determine the MIME type of a new document. +* Force object to text when raising PermissionDenied to avoid + UnicodeDecodeError. Thanks to Mathias Behrle (@mbehrle) for the report + and the debug information. GitLab issue #576. 3.1.9 (2018-11-01) diff --git a/docs/releases/3.1.10.rst b/docs/releases/3.1.10.rst index 49aadf5717..ac538307cb 100644 --- a/docs/releases/3.1.10.rst +++ b/docs/releases/3.1.10.rst @@ -182,5 +182,7 @@ Bugs fixed or issues closed * :gitlab-issue:`572` Error when sending compressed files: ziparchive object has no attribute children * :gitlab-issue:`574` import of E-Mails with empty attachment fails +* :gitlab-issue:`576` Exception with access check for cabinets containing + NON-ASCII chars .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/acls/managers.py b/mayan/apps/acls/managers.py index 995be822e0..914fc0a790 100644 --- a/mayan/apps/acls/managers.py +++ b/mayan/apps/acls/managers.py @@ -6,6 +6,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.exceptions import PermissionDenied from django.db import models from django.db.models import Q +from django.utils.encoding import force_text from django.utils.translation import ugettext, ugettext_lazy as _ from common.utils import return_attrib, return_related @@ -54,7 +55,11 @@ class AccessControlListManager(models.Manager): except AttributeError: # AttributeError means non model objects: ie Statistics # These can't have ACLs so we raise PermissionDenied - raise PermissionDenied(_('Insufficient access for: %s') % obj) + + # Force object to text to avoid UnicodeDecodeError + raise PermissionDenied( + ugettext('Insufficient access for: %s') % force_text(obj) + ) except KeyError: pass else: @@ -93,7 +98,9 @@ class AccessControlListManager(models.Manager): 'Permissions "%s" on "%s" denied for user "%s"', permissions, obj, user ) - raise PermissionDenied(ugettext('Insufficient access for: %s') % obj) + raise PermissionDenied( + ugettext('Insufficient access for: %s') % force_text(obj) + ) logger.debug( 'Permissions "%s" on "%s" granted to user "%s" through roles "%s" by direct ACL',