[IMP] web_editor, base: allow parameters in image URLs
When adding an image to the library from an URL, if the URL contains parameters (e.g. ?width=200&height=200), the link will not be accepted. In this commit, we remove these parameters from the URL before checking the image, so that the URL is considered valid. We also remove these parameters before computing the mimetype of the image, since it is computed based on the end part of the URL. task-2618494 Part-of: odoo/odoo#75205
This commit is contained in:
committed by
Romain Derie
parent
e1ad97a7d3
commit
85cb19b294
@@ -658,7 +658,7 @@ var FileWidget = SearchableMediaWidget.extend({
|
||||
* @private
|
||||
*/
|
||||
_onURLInputChange: function () {
|
||||
var inputValue = this.$urlInput.val();
|
||||
const inputValue = this.$urlInput.val().split('?')[0];
|
||||
var emptyValue = (inputValue === '');
|
||||
|
||||
var isURL = /^.+\..+$/.test(inputValue); // TODO improve
|
||||
|
||||
@@ -283,7 +283,7 @@ class IrAttachment(models.Model):
|
||||
if not mimetype and values.get('name'):
|
||||
mimetype = mimetypes.guess_type(values['name'])[0]
|
||||
if not mimetype and values.get('url'):
|
||||
mimetype = mimetypes.guess_type(values['url'])[0]
|
||||
mimetype = mimetypes.guess_type(values['url'].split('?')[0])[0]
|
||||
if not mimetype or mimetype == 'application/octet-stream':
|
||||
raw = None
|
||||
if values.get('raw'):
|
||||
|
||||
Reference in New Issue
Block a user