autumnnote 1.11.0 → 1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/autumnnote.es.js +54 -3
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +54 -3
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/js/core/sanitise.js +47 -2
- package/src/js/index.js +1 -1
- package/types/index.d.ts +1 -1
package/dist/autumnnote.es.js
CHANGED
|
@@ -4643,7 +4643,10 @@ var PROHIBITED_TAGS = [
|
|
|
4643
4643
|
"object",
|
|
4644
4644
|
"embed",
|
|
4645
4645
|
"form",
|
|
4646
|
-
"base"
|
|
4646
|
+
"base",
|
|
4647
|
+
"template",
|
|
4648
|
+
"link",
|
|
4649
|
+
"meta"
|
|
4647
4650
|
];
|
|
4648
4651
|
/** Tags whose element wrapper is stripped but content (child nodes) is preserved. */
|
|
4649
4652
|
var UNWRAP_TAGS = new Set(["button"]);
|
|
@@ -4652,8 +4655,28 @@ var URL_ATTRS = [
|
|
|
4652
4655
|
"href",
|
|
4653
4656
|
"src",
|
|
4654
4657
|
"action",
|
|
4655
|
-
"formaction"
|
|
4658
|
+
"formaction",
|
|
4659
|
+
"xlink:href"
|
|
4656
4660
|
];
|
|
4661
|
+
/** Inline style properties the editor's own toolbar/table features persist on saved content. */
|
|
4662
|
+
var ALLOWED_STYLE_PROPS = new Set([
|
|
4663
|
+
"color",
|
|
4664
|
+
"background-color",
|
|
4665
|
+
"font-size",
|
|
4666
|
+
"line-height",
|
|
4667
|
+
"text-align",
|
|
4668
|
+
"vertical-align",
|
|
4669
|
+
"width",
|
|
4670
|
+
"min-width",
|
|
4671
|
+
"height",
|
|
4672
|
+
"min-height",
|
|
4673
|
+
"border-width",
|
|
4674
|
+
"border-style",
|
|
4675
|
+
"border-color",
|
|
4676
|
+
"padding"
|
|
4677
|
+
]);
|
|
4678
|
+
/** Value patterns that are never safe regardless of property. */
|
|
4679
|
+
var DANGEROUS_STYLE_VALUE_RE = /url\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i;
|
|
4657
4680
|
/** Trusted hosts for iframe embeds when allowIframes is enabled. */
|
|
4658
4681
|
var TRUSTED_IFRAME_HOSTS = new Set([
|
|
4659
4682
|
"www.youtube.com",
|
|
@@ -4694,6 +4717,12 @@ function sanitiseHTML(html, { allowIframes = false } = {}) {
|
|
|
4694
4717
|
el.removeAttribute(attr.name);
|
|
4695
4718
|
continue;
|
|
4696
4719
|
}
|
|
4720
|
+
if (attr.name === "style") {
|
|
4721
|
+
const cleaned = sanitiseStyleValue(attr.value);
|
|
4722
|
+
if (cleaned) el.setAttribute("style", cleaned);
|
|
4723
|
+
else el.removeAttribute("style");
|
|
4724
|
+
continue;
|
|
4725
|
+
}
|
|
4697
4726
|
if (URL_ATTRS.includes(attr.name)) {
|
|
4698
4727
|
const val = attr.value.trim();
|
|
4699
4728
|
if (/^(javascript|vbscript):/i.test(val)) {
|
|
@@ -4722,6 +4751,28 @@ function sanitiseHTML(html, { allowIframes = false } = {}) {
|
|
|
4722
4751
|
return doc.body.innerHTML;
|
|
4723
4752
|
}
|
|
4724
4753
|
/**
|
|
4754
|
+
* Filters a style attribute value down to an allowlisted set of CSS
|
|
4755
|
+
* properties (ALLOWED_STYLE_PROPS), dropping any declaration whose value
|
|
4756
|
+
* contains a dangerous construct — url(), expression(), an "import" rule,
|
|
4757
|
+
* javascript:/vbscript:, IE behavior/-moz-binding — regardless of property.
|
|
4758
|
+
* @param {string} value
|
|
4759
|
+
* @returns {string} The filtered declaration list, or '' if nothing survives.
|
|
4760
|
+
*/
|
|
4761
|
+
function sanitiseStyleValue(value) {
|
|
4762
|
+
const kept = [];
|
|
4763
|
+
for (const decl of (value || "").split(";")) {
|
|
4764
|
+
const idx = decl.indexOf(":");
|
|
4765
|
+
if (idx === -1) continue;
|
|
4766
|
+
const prop = decl.slice(0, idx).trim().toLowerCase();
|
|
4767
|
+
const val = decl.slice(idx + 1).trim();
|
|
4768
|
+
if (!prop || !val) continue;
|
|
4769
|
+
if (!ALLOWED_STYLE_PROPS.has(prop)) continue;
|
|
4770
|
+
if (DANGEROUS_STYLE_VALUE_RE.test(val)) continue;
|
|
4771
|
+
kept.push(`${prop}: ${val}`);
|
|
4772
|
+
}
|
|
4773
|
+
return kept.join("; ");
|
|
4774
|
+
}
|
|
4775
|
+
/**
|
|
4725
4776
|
* Returns true if iframe src points to an approved video host.
|
|
4726
4777
|
* Relative, protocol-relative and invalid URLs are rejected.
|
|
4727
4778
|
* @param {string} src
|
|
@@ -17911,7 +17962,7 @@ var AutumnNote = {
|
|
|
17911
17962
|
/** All pre-built button definitions — accessible in every module format including UMD/CJS. */
|
|
17912
17963
|
buttons,
|
|
17913
17964
|
/** Library version */
|
|
17914
|
-
version: "1.11.
|
|
17965
|
+
version: "1.11.1"
|
|
17915
17966
|
};
|
|
17916
17967
|
/**
|
|
17917
17968
|
* @param {string|Element|NodeList|Element[]} selector
|