[FIX] P3: resizing of image *fields*
Fields sent from the client are pretty much always *text*. This can be problematic for image fields sent as base64 *text* as in Python 3 the base64 routines only work between bytes. Alter the core field-resizing function (image_get_resized_images) such that it ensures text base64 sources are encoded back to bytes before being forwarded to the main resizing routines (which I don't think should deal with *that* issue). Fixes #18985: error when trying to update a company's logo
This commit is contained in:
@@ -9,6 +9,8 @@ from PIL import ImageEnhance
|
||||
from random import randrange
|
||||
|
||||
# Preload PIL with the minimal subset of image formats we need
|
||||
from odoo.tools import pycompat
|
||||
|
||||
Image.preinit()
|
||||
Image._initialized = 2
|
||||
|
||||
@@ -253,6 +255,8 @@ def image_get_resized_images(base64_source, return_big=False, return_medium=True
|
||||
previous parameters.
|
||||
"""
|
||||
return_dict = dict()
|
||||
if isinstance(base64_source, pycompat.text_type):
|
||||
base64_source = base64_source.encode('ascii')
|
||||
if return_big:
|
||||
return_dict[big_name] = image_resize_image_big(base64_source, avoid_if_small=avoid_resize_big)
|
||||
if return_medium:
|
||||
|
||||
Reference in New Issue
Block a user