[FIX] strip XML comments out of templates

closes #47
This commit is contained in:
Géry Debongnie
2019-04-17 16:13:52 +02:00
parent 4a07e65102
commit f466495f75
+3 -2
View File
@@ -163,8 +163,9 @@ class App extends Component {
// check templates // check templates
var qweb = new owl.QWeb(); var qweb = new owl.QWeb();
var error = false; var error = false;
const sanitizedXML = this.state.xml.replace(/<!--[\s\S]*?-->/g, "");
try { try {
qweb.loadTemplates(this.state.xml); qweb.loadTemplates(sanitizedXML);
} catch (e) { } catch (e) {
error = e; error = e;
} }
@@ -190,7 +191,7 @@ class App extends Component {
owlScript.addEventListener("load", () => { owlScript.addEventListener("load", () => {
const script = doc.createElement("script"); const script = doc.createElement("script");
script.type = "text/javascript"; script.type = "text/javascript";
const content = `window.TEMPLATES = \`${this.state.xml}\`\n${ const content = `window.TEMPLATES = \`${sanitizedXML}\`\n${
this.state.js this.state.js
}`; }`;
script.innerHTML = content; script.innerHTML = content;