From 3467d272614ed9e404bfbf9ffc347676907e0751 Mon Sep 17 00:00:00 2001 From: Fabien Meghazi Date: Thu, 21 Feb 2013 18:23:27 +0100 Subject: [PATCH] [FIX] Unsupported self closing tags shall not reach FormRenderingEngine bzr revid: fme@openerp.com-20130221172327-0dydqn548av5vkqo --- addons/web/static/src/js/views.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/addons/web/static/src/js/views.js b/addons/web/static/src/js/views.js index 31f3df4a746..0e55d2b3ea5 100644 --- a/addons/web/static/src/js/views.js +++ b/addons/web/static/src/js/views.js @@ -1547,13 +1547,22 @@ instance.web.json_node_to_xml = function(node, human_readable, indent) { } }; instance.web.xml_to_str = function(node) { + var str = ""; if (window.XMLSerializer) { - return (new XMLSerializer()).serializeToString(node); + str = (new XMLSerializer()).serializeToString(node); } else if (window.ActiveXObject) { - return node.xml; + str = node.xml; } else { throw new Error(_t("Could not serialize XML")); } + // Browsers won't deal with self closing tags except br, hr, input, ... + // http://stackoverflow.com/questions/97522/what-are-all-the-valid-self-closing-elements-in-xhtml-as-implemented-by-the-maj + // + // The following regex is a bit naive but it's ok for the xmlserializer output + str = str.replace(/<([a-z]+)([^<>]*)\s?\/\s?>/g, function(match, tag, attrs) { + return "<" + tag + attrs + ">"; + }); + return str; }; /**