diff --git a/openslides/mediafiles/serializers.py b/openslides/mediafiles/serializers.py index 368404485..3eacc057b 100644 --- a/openslides/mediafiles/serializers.py +++ b/openslides/mediafiles/serializers.py @@ -3,6 +3,7 @@ import mimetypes from django.conf import settings from django.db import models as dbmodels from PyPDF2 import PdfFileReader +from PyPDF2.utils import PdfReadError from ..utils.rest_api import FileField, ModelSerializer, SerializerMethodField from .models import Mediafile @@ -29,6 +30,10 @@ class AngularCompatibleFileField(FileField): except FileNotFoundError: # File was deleted from server. Set 'pages' to 0. result['pages'] = 0 + except PdfReadError: + # File could be encrypted but not be detected by PyPDF. + result['pages'] = 0 + result['encrypted'] = True return result diff --git a/openslides/mediafiles/static/js/mediafiles/base.js b/openslides/mediafiles/static/js/mediafiles/base.js index 736644988..534877d55 100644 --- a/openslides/mediafiles/static/js/mediafiles/base.js +++ b/openslides/mediafiles/static/js/mediafiles/base.js @@ -53,7 +53,7 @@ angular.module('OpenSlidesApp.mediafiles', []) return _.includes(VIDEO_FILE_TYPES, filetype); }], is_presentable: ['is_pdf', 'is_image', 'is_video', function (is_pdf, is_image, is_video) { - return is_pdf || is_image || is_video; + return (is_pdf && !this.mediafile.encrypted) || is_image || is_video; }], mediafileUrl: [function () { return this.media_url_prefix + this.mediafile.name; diff --git a/openslides/mediafiles/static/templates/mediafiles/mediafile-list.html b/openslides/mediafiles/static/templates/mediafiles/mediafile-list.html index a33805e95..cf9f5515f 100644 --- a/openslides/mediafiles/static/templates/mediafiles/mediafile-list.html +++ b/openslides/mediafiles/static/templates/mediafiles/mediafile-list.html @@ -233,7 +233,9 @@