Univention Bugzilla – Attachment 6583 Details for
Bug 36273
allow PNG as user photo
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
36273.patch (text/plain), 2.38 KB, created by
Florian Best
on 2015-01-08 15:51 CET
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Florian Best
Created:
2015-01-08 15:51 CET
Size:
2.38 KB
patch
obsolete
>diff --git a/ucs-4.0-0/management/univention-directory-manager-modules/debian/control b/ucs-4.0-0/management/univention-directory-manager-modules/debian/control >index d1f3ae4..305cb73 100644 >--- a/ucs-4.0-0/management/univention-directory-manager-modules/debian/control >+++ b/ucs-4.0-0/management/univention-directory-manager-modules/debian/control >@@ -21,6 +21,7 @@ Depends: ${misc:Depends}, ${python:Depends}, > python-m2crypto, > python-smbpasswd, > shell-univention-lib, >+ python-imaging, > python-univention-lib (>= 3.0.26-50), > python-univention-directory-manager-cli (= ${binary:Version}) > Provides: ${python:Provides} >diff --git a/ucs-4.0-0/management/univention-directory-manager-modules/modules/univention/admin/syntax.py b/ucs-4.0-0/management/univention-directory-manager-modules/modules/univention/admin/syntax.py >index 28e289d..a008e03 100644 >--- a/ucs-4.0-0/management/univention-directory-manager-modules/modules/univention/admin/syntax.py >+++ b/ucs-4.0-0/management/univention-directory-manager-modules/modules/univention/admin/syntax.py >@@ -30,7 +30,8 @@ > # /usr/share/common-licenses/AGPL-3; if not, see > # <http://www.gnu.org/licenses/>. > >-import re, operator >+import re >+import operator > import ipaddr > import inspect > import univention.debug >@@ -46,8 +47,12 @@ import base64 > import zlib > import bz2 > import copy >-import sys, os >+import sys >+import os > import shlex >+import imghdr >+import PIL >+from io import BytesIO > > translation=univention.admin.localization.translation('univention/admin') > _=translation.translate >@@ -444,9 +449,25 @@ class jpegPhoto( Upload ): > @classmethod > def parse(self, text): > try: >+ raw = base64.b64decode(text) >+ if imghdr.what(None, raw) == 'png': >+ # convert from PNG to JPEG >+ try: >+ fp = BytesIO(raw) >+ text = BytesIO() >+ image = PIL.Image.open(fp) >+ def _fileno(*a,**k): >+ raise AttributeError() >+ text.fileno = _fileno >+ image.save(open('/tmp/test', 'w'), format='jpeg') >+ image.save(text, format='jpeg') >+ raw = text.getvalue() >+ text = base64.b64encode(raw) >+ except (KeyError, IOError): >+ raise > # imghdr.what(None, base64.b64dcode(text)) == 'jpeg' # See Bug #36304 > ## this is what imghdr.py probably does in the future: >- if base64.b64decode(text)[0:2] != b'\xff\xd8': >+ if raw[0:2] != b'\xff\xd8': > raise ValueError > return text > except (base64.binascii.Error, ValueError, TypeError):
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 36273
: 6583