Bug 36304 - Unable to upload this image for a user
Unable to upload this image for a user
Product: UCS
Classification: Unclassified
Component: UMC - Users
UCS 4.0
Other Linux
: P5 normal (vote)
: UCS 4.0
Assigned To: Arvid Requate
Florian Best
: interim-3
Depends on:
  Show dependency treegraph
Reported: 2014-10-27 08:56 CET by Stefan Gohmann
Modified: 2014-11-26 06:54 CET (History)
1 user (show)

See Also:
What kind of report is it?: ---
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted after Product Owner Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:

Photo-0010.jpg (81.59 KB, image/jpeg)
2014-10-27 08:56 CET, Stefan Gohmann

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Gohmann univentionstaff 2014-10-27 08:56:50 CET
Created attachment 6237 [details]

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
Comment 1 Florian Best univentionstaff 2014-10-27 09:30:35 CET
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'
Comment 2 Arvid Requate univentionstaff 2014-10-29 13:48:25 CET
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.
Comment 3 Florian Best univentionstaff 2014-11-03 20:48:56 CET
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.
Comment 4 Florian Best univentionstaff 2014-11-04 10:49:06 CET
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
    if base64.b64decode(text)[0:2] != b'\xff\xd8'
        raise ValueError
except (base64.binascii.Error, ValueError, TypeError):
    raise blah…
Comment 5 Arvid Requate univentionstaff 2014-11-04 12:53:42 CET
Ok, adjusted.
Comment 6 Florian Best univentionstaff 2014-11-04 15:18:52 CET
OK, I tested a lot of different JPEG formats.
OK: Exception handling
OK: Changelog
Comment 7 Stefan Gohmann univentionstaff 2014-11-26 06:54:38 CET
UCS 4.0-0 has been released:

If this error occurs again, please use "Clone This Bug".