Skip to content
Snippets Groups Projects
Commit 43184556 authored by Saurabh Choraria's avatar Saurabh Choraria
Browse files

[FIX] base: handle error when editing comment in view's architecture


Currently, When the user is adding a double hyphen or space or anything within a
comment in a view's architecture and tries to save the view, then an error
occurs.

To reproduce the issue:
1. Go to Settings > Technical > Views > open a view.
2. In View Architecture comment out a line.
3. Add a double hyphen or space or anything within the comment.
4. Then save manually, the error will occur.

To solve this issue the error has been handled using a try-except block in
'parse_html' method.

sentry-4306359331

closes odoo/odoo#129969

Signed-off-by: default avatarNicolas Lempereur (nle) <nle@odoo.com>
parent bde8aa9f
No related branches found
No related tags found
No related merge requests found
...@@ -12024,6 +12024,15 @@ msgstr "" ...@@ -12024,6 +12024,15 @@ msgstr ""
msgid "Error message returned when the constraint is violated." msgid "Error message returned when the constraint is violated."
msgstr "" msgstr ""
   
#. module: base
#: code:addons/translate.py:0
#, python-format
msgid ""
"Error while parsing view:\n"
"\n"
"%s"
msgstr ""
#. module: base #. module: base
#: code:addons/base/models/ir_ui_view.py:0 #: code:addons/base/models/ir_ui_view.py:0
#, python-format #, python-format
......
...@@ -22,6 +22,7 @@ from babel.messages import extract ...@@ -22,6 +22,7 @@ from babel.messages import extract
from lxml import etree, html from lxml import etree, html
import odoo import odoo
from odoo.exceptions import UserError
from . import config, pycompat from . import config, pycompat
from .misc import file_open, get_iso_codes, SKIPPED_ELEMENT_TYPES from .misc import file_open, get_iso_codes, SKIPPED_ELEMENT_TYPES
...@@ -295,7 +296,11 @@ def serialize_xml(node): ...@@ -295,7 +296,11 @@ def serialize_xml(node):
_HTML_PARSER = etree.HTMLParser(encoding='utf8') _HTML_PARSER = etree.HTMLParser(encoding='utf8')
def parse_html(text): def parse_html(text):
return html.fragment_fromstring(text, parser=_HTML_PARSER) try:
parse = html.fragment_fromstring(text, parser=_HTML_PARSER)
except TypeError as e:
raise UserError(_("Error while parsing view:\n\n%s") % e) from e
return parse
def serialize_html(node): def serialize_html(node):
return etree.tostring(node, method='html', encoding='unicode') return etree.tostring(node, method='html', encoding='unicode')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment