Univention Bugzilla – Bug 36304
Unable to upload this image for a user
Last modified: 2014-11-26 06:54:38 CET
Created attachment 6237 [details] Photo-0010.jpg I'm unable to upload this image for a user. I got the following message: The following properties could not be validated: Picture of the user (JPEG format): Value must be Base64 encoded jpeg
The image starts with: '\xff\xd8\xff\xe3\x00 SGH-D500 JPG IMAGE\x00\x00\x00\x00\x00\x00\x00\x00' but imghdr recognizes only the following as JPEG: 38 def test_jpeg(h, f): 39 """JPEG data in JFIF format""" 40 if h[6:10] == 'JFIF': 41 return 'jpeg' 45 def test_exif(h, f): 46 """JPEG data in Exif format""" 47 if h[6:10] == 'Exif': 48 return 'jpeg'
While this imghdr.test_jpeg gets fixed I avoid it in the udm jpeg syntax and manually perform the check that was agreed upon upstream, see URL.
hm, why don't just uncomment the line instead of removing it so that it can be reimplemented when the problem is fixed upstream? (The upstream bug is not set to resolved nor verified yet, so maybe the fix contains errors again). Also the 'assert' statement shouldn't be used for such things, some precompiling of bytecode removes assertions.
Since I am QA, I reopen this bug because of comment #3. Please make that small adjustment, to add the comment and don't use assert: # imghdr.what(None, base64.b64dcode(text)) == 'jpeg' # See Bug #36304 blah try: if base64.b64decode(text)[0:2] != b'\xff\xd8' raise ValueError except (base64.binascii.Error, ValueError, TypeError): raise blah…
Ok, adjusted.
OK, I tested a lot of different JPEG formats. OK: Exception handling OK: Changelog
UCS 4.0-0 has been released: http://docs.univention.de/release-notes-4.0-0-en.html http://docs.univention.de/release-notes-4.0-0-de.html If this error occurs again, please use "Clone This Bug".