mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
SECURITY: Sanitize d-popover attributes (#13958)
This commit is contained in:
parent
bb2c48b065
commit
38199424bc
@ -16,8 +16,7 @@ const D_ARROW_HEIGHT = 10;
|
|||||||
|
|
||||||
const D_HORIZONTAL_MARGIN = 5;
|
const D_HORIZONTAL_MARGIN = 5;
|
||||||
|
|
||||||
export const POPOVER_SELECTORS =
|
export const POPOVER_SELECTORS = "[data-popover], [data-tooltip]";
|
||||||
"[data-html-popover], [data-html-tooltip], [data-popover], [data-tooltip]";
|
|
||||||
|
|
||||||
export function hidePopover() {
|
export function hidePopover() {
|
||||||
getPopover().fadeOut().remove();
|
getPopover().fadeOut().remove();
|
||||||
@ -55,11 +54,6 @@ export function showPopover(event, options = {}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setPopoverHtmlContent($enteredElement, content) {
|
function setPopoverHtmlContent($enteredElement, content) {
|
||||||
content =
|
|
||||||
content ||
|
|
||||||
$enteredElement.attr("data-html-popover") ||
|
|
||||||
$enteredElement.attr("data-html-tooltip");
|
|
||||||
|
|
||||||
replaceHtmlContent($enteredElement, content);
|
replaceHtmlContent($enteredElement, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +136,11 @@ module("Unit | Utility | sanitizer", function () {
|
|||||||
);
|
);
|
||||||
|
|
||||||
cooked(`<div dir="rtl">RTL text</div>`, `<div dir="rtl">RTL text</div>`);
|
cooked(`<div dir="rtl">RTL text</div>`, `<div dir="rtl">RTL text</div>`);
|
||||||
|
|
||||||
|
cooked(
|
||||||
|
`<div data-value="<something>" data-html-value="<something>"></div>`,
|
||||||
|
`<div data-value="<something>"></div>`
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("ids on headings", function (assert) {
|
test("ids on headings", function (assert) {
|
||||||
|
@ -75,7 +75,9 @@ export function sanitize(text, allowLister) {
|
|||||||
if (
|
if (
|
||||||
(forAttr &&
|
(forAttr &&
|
||||||
(forAttr.indexOf("*") !== -1 || forAttr.indexOf(value) !== -1)) ||
|
(forAttr.indexOf("*") !== -1 || forAttr.indexOf(value) !== -1)) ||
|
||||||
(name.indexOf("data-") === 0 && forTag["data-*"]) ||
|
(name.indexOf("data-html-") === -1 &&
|
||||||
|
name.indexOf("data-") === 0 &&
|
||||||
|
forTag["data-*"]) ||
|
||||||
(tag === "a" &&
|
(tag === "a" &&
|
||||||
name === "href" &&
|
name === "href" &&
|
||||||
hrefAllowed(value, extraHrefMatchers)) ||
|
hrefAllowed(value, extraHrefMatchers)) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user