From 8c0bc4f4b81db820fe984ebc4d209894a8041f39 Mon Sep 17 00:00:00 2001 From: Patrick Hoste Date: Thu, 4 Jun 2020 12:13:16 +0000 Subject: [PATCH] [FIX] web: fix image widget when record name is .. PURPOSE Before this commit, when you used the 'image' widget when the record name was ``..`` (double dots) it couldn't retrieve the image since the double dots was decoded as the parent directory shortcut. After this commit, the double dots will be replaced by -- with the downside to loose the true record name. SPECIFICATIONS Replace the .. (double dots) with -- in the filename. Using .. may seem like a strange use case but if you actually try to find a partner called ".." in a production database, you might be surprised ... LINKS Task ID-2241513 (eLearning onboarding and testing) PR #55567 X-original-commit: dcb7a924c36cd3f3aeef891ddd8830bd66322025 --- addons/web/models/ir_qweb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web/models/ir_qweb.py b/addons/web/models/ir_qweb.py index 4ffab27bd5e..875899f7d57 100644 --- a/addons/web/models/ir_qweb.py +++ b/addons/web/models/ir_qweb.py @@ -52,7 +52,7 @@ class Image(models.AbstractModel): filename = options['filename'] else: filename = record.display_name - filename = filename.replace('/', '-').replace('\\', '-') + filename = filename.replace('/', '-').replace('\\', '-').replace('..', '--') src = '/web/image/%s/%s/%s%s/%s?unique=%s' % (record._name, record.id, options.get('preview_image', field_name), max_size, url_quote(filename), sha)