Skip to content

Commit d2de22d

Browse files
ged-odooFrancoisGe
authored andcommitted
small security focused changes
1 parent 6179691 commit d2de22d

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

addons/html_builder/static/src/core/anchor/anchor_plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { _t } from "@web/core/l10n/translation";
55
import { markup } from "@odoo/owl";
66
import { AnchorDialog } from "./anchor_dialog";
77
import { getElementsWithOption } from "@html_builder/utils/utils";
8+
import { escape } from "@web/core/utils/strings";
89

910
const anchorSelector = ":not(p).oe_structure > *, :not(p)[data-oe-type=html] > *";
1011
const anchorExclude =
@@ -91,7 +92,7 @@ export class AnchorPlugin extends Plugin {
9192
}
9293
const anchorLink = this.getAnchorLink(element);
9394
await browser.navigator.clipboard.writeText(anchorLink);
94-
const message = markup(_t("Anchor copied to clipboard<br>Link: %s", anchorLink));
95+
const message = markup(_t("Anchor copied to clipboard<br>Link: %s", escape(anchorLink)));
9596
const closeNotification = this.services.notification.add(message, {
9697
type: "success",
9798
buttons: [

addons/html_builder/static/src/core/building_blocks/builder_select.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from "../utils";
1010
import { BuilderComponent } from "./builder_component";
1111
import { useDropdownState } from "@web/core/dropdown/dropdown_hooks";
12+
import { setElementContent } from "@web/core/utils/html";
1213

1314
export class WithIgnoreItem extends Component {
1415
static template = xml`<t t-slot="default"/>`;
@@ -52,7 +53,7 @@ export class BuilderSelect extends Component {
5253
if (!this.props.slots.fixedButton) {
5354
const newHtml = currentLabel || _t("None");
5455
if (buttonRef.el && buttonRef.el.innerHTML !== newHtml) {
55-
buttonRef.el.innerHTML = newHtml;
56+
setElementContent(buttonRef.el, newHtml);
5657
}
5758
}
5859
};

addons/html_builder/static/src/core/building_blocks/builder_select_item.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, onMounted, useRef } from "@odoo/owl";
1+
import { Component, markup, onMounted, useRef } from "@odoo/owl";
22
import { getActiveHotkey } from "@web/core/hotkeys/hotkey_service";
33
import {
44
clickableBuilderComponentProps,
@@ -32,7 +32,8 @@ export class BuilderSelectItem extends Component {
3232
// todo: it's not clear why the item.el?.innerHTML is not set at in
3333
// some cases. We fallback on a previously set value to circumvent
3434
// the problem, but it should be investigated.
35-
label = this.props.label || item.el?.innerHTML || label || "";
35+
36+
label = this.props.label || (item.el ? markup(item.el.innerHTML) : "") || label || "";
3637
return label;
3738
};
3839

addons/html_builder/static/src/core/save_snippet_plugin.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Plugin } from "@html_editor/plugin";
22
import { withSequence } from "@html_editor/utils/resource";
33
import { markup } from "@odoo/owl";
44
import { _t } from "@web/core/l10n/translation";
5+
import { escape } from "@web/core/utils/strings";
56

67
const savableSelector = "[data-snippet], a.btn";
78
// TODO `so_submit_button_selector` ?
@@ -42,7 +43,7 @@ export class SaveSnippetPlugin extends Plugin {
4243
const message = markup(
4344
_t(
4445
"Your custom snippet was successfully saved as <strong>%s</strong>. Find it in your snippets collection.",
45-
savedName
46+
escape(savedName)
4647
)
4748
);
4849
this.services.notification.add(message, {

addons/website/static/src/client_actions/website_preview/website_builder_action.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ export class WebsiteBuilder extends Component {
397397
this.setIframeLoaded();
398398
this.websiteService.websiteRootInstance = undefined;
399399
if (url) {
400-
this.websiteContent.el.contentWindow.location = url;
400+
this.websiteContent.el.contentWindow.location = encodeURIComponent(url);
401401
} else {
402402
this.websiteContent.el.contentWindow.location.reload();
403403
}

0 commit comments

Comments
 (0)