From 8d06889ec3b4f7234ebe9e8f524b286e5dcffa29 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 1 Sep 2023 07:24:28 +0000 Subject: [PATCH] [FIX] base: encoding guessing of html module descriptions I missed a critical issue in #133708: various users had discovered they could already fix description issues by adding an XML declaration to their document which is very cool (though technically not really valid). What is a lot less cool is that lxml gets *extremely* unhappy when asked to parse *strings* with an encoding declaration, raising a ValueError, so the purported fix breaks on any module which does that, which seems to include a lot of OCA modules. Gate the encoding guessing by bailing if the document has an XML declaration, in which case we just assume the author knows what they're doing and we leave them alone. For extra safety, check the encoding declaration in ascii and utf16. Could also have checked for BOMs, but lxml seems to not care about them overly much (in fact it seems to prefer them decoded which is odd). Also same as non-utf8 descriptions, mark XML declarations as deprecated (because it's a hack to make UTF8 descriptions work which is not necessary anymore). closes odoo/odoo#133968 Reported-by: @rezak400 X-original-commit: fd353d7d0104431208b91603431e41ef4a6e54bb Signed-off-by: Xavier Morel (xmo) --- odoo/addons/base/models/ir_module.py | 29 ++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 039429209a1..fed9a5a0474 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -134,6 +134,13 @@ STATES = [ ] +XML_DECLARATION = ( + '