autumnnote 1.11.0 → 1.12.0
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/_headers +5 -0
- 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/dist/sitemap.xml +3 -0
- 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.umd.js
CHANGED
|
@@ -4356,7 +4356,10 @@
|
|
|
4356
4356
|
"object",
|
|
4357
4357
|
"embed",
|
|
4358
4358
|
"form",
|
|
4359
|
-
"base"
|
|
4359
|
+
"base",
|
|
4360
|
+
"template",
|
|
4361
|
+
"link",
|
|
4362
|
+
"meta"
|
|
4360
4363
|
];
|
|
4361
4364
|
/** Tags whose element wrapper is stripped but content (child nodes) is preserved. */
|
|
4362
4365
|
var UNWRAP_TAGS = new Set(["button"]);
|
|
@@ -4365,8 +4368,28 @@
|
|
|
4365
4368
|
"href",
|
|
4366
4369
|
"src",
|
|
4367
4370
|
"action",
|
|
4368
|
-
"formaction"
|
|
4371
|
+
"formaction",
|
|
4372
|
+
"xlink:href"
|
|
4369
4373
|
];
|
|
4374
|
+
/** Inline style properties the editor's own toolbar/table features persist on saved content. */
|
|
4375
|
+
var ALLOWED_STYLE_PROPS = new Set([
|
|
4376
|
+
"color",
|
|
4377
|
+
"background-color",
|
|
4378
|
+
"font-size",
|
|
4379
|
+
"line-height",
|
|
4380
|
+
"text-align",
|
|
4381
|
+
"vertical-align",
|
|
4382
|
+
"width",
|
|
4383
|
+
"min-width",
|
|
4384
|
+
"height",
|
|
4385
|
+
"min-height",
|
|
4386
|
+
"border-width",
|
|
4387
|
+
"border-style",
|
|
4388
|
+
"border-color",
|
|
4389
|
+
"padding"
|
|
4390
|
+
]);
|
|
4391
|
+
/** Value patterns that are never safe regardless of property. */
|
|
4392
|
+
var DANGEROUS_STYLE_VALUE_RE = /url\s*\(|expression\s*\(|@import|javascript:|vbscript:|behavior\s*:|-moz-binding/i;
|
|
4370
4393
|
/** Trusted hosts for iframe embeds when allowIframes is enabled. */
|
|
4371
4394
|
var TRUSTED_IFRAME_HOSTS = new Set([
|
|
4372
4395
|
"www.youtube.com",
|
|
@@ -4407,6 +4430,12 @@
|
|
|
4407
4430
|
el.removeAttribute(attr.name);
|
|
4408
4431
|
continue;
|
|
4409
4432
|
}
|
|
4433
|
+
if (attr.name === "style") {
|
|
4434
|
+
const cleaned = sanitiseStyleValue(attr.value);
|
|
4435
|
+
if (cleaned) el.setAttribute("style", cleaned);
|
|
4436
|
+
else el.removeAttribute("style");
|
|
4437
|
+
continue;
|
|
4438
|
+
}
|
|
4410
4439
|
if (URL_ATTRS.includes(attr.name)) {
|
|
4411
4440
|
const val = attr.value.trim();
|
|
4412
4441
|
if (/^(javascript|vbscript):/i.test(val)) {
|
|
@@ -4435,6 +4464,28 @@
|
|
|
4435
4464
|
return doc.body.innerHTML;
|
|
4436
4465
|
}
|
|
4437
4466
|
/**
|
|
4467
|
+
* Filters a style attribute value down to an allowlisted set of CSS
|
|
4468
|
+
* properties (ALLOWED_STYLE_PROPS), dropping any declaration whose value
|
|
4469
|
+
* contains a dangerous construct — url(), expression(), an "import" rule,
|
|
4470
|
+
* javascript:/vbscript:, IE behavior/-moz-binding — regardless of property.
|
|
4471
|
+
* @param {string} value
|
|
4472
|
+
* @returns {string} The filtered declaration list, or '' if nothing survives.
|
|
4473
|
+
*/
|
|
4474
|
+
function sanitiseStyleValue(value) {
|
|
4475
|
+
const kept = [];
|
|
4476
|
+
for (const decl of (value || "").split(";")) {
|
|
4477
|
+
const idx = decl.indexOf(":");
|
|
4478
|
+
if (idx === -1) continue;
|
|
4479
|
+
const prop = decl.slice(0, idx).trim().toLowerCase();
|
|
4480
|
+
const val = decl.slice(idx + 1).trim();
|
|
4481
|
+
if (!prop || !val) continue;
|
|
4482
|
+
if (!ALLOWED_STYLE_PROPS.has(prop)) continue;
|
|
4483
|
+
if (DANGEROUS_STYLE_VALUE_RE.test(val)) continue;
|
|
4484
|
+
kept.push(`${prop}: ${val}`);
|
|
4485
|
+
}
|
|
4486
|
+
return kept.join("; ");
|
|
4487
|
+
}
|
|
4488
|
+
/**
|
|
4438
4489
|
* Returns true if iframe src points to an approved video host.
|
|
4439
4490
|
* Relative, protocol-relative and invalid URLs are rejected.
|
|
4440
4491
|
* @param {string} src
|
|
@@ -17498,7 +17549,7 @@
|
|
|
17498
17549
|
/** All pre-built button definitions — accessible in every module format including UMD/CJS. */
|
|
17499
17550
|
buttons,
|
|
17500
17551
|
/** Library version */
|
|
17501
|
-
version: "1.
|
|
17552
|
+
version: "1.12.0"
|
|
17502
17553
|
};
|
|
17503
17554
|
/**
|
|
17504
17555
|
* @param {string|Element|NodeList|Element[]} selector
|