@hyperframes/core 0.9.88 → 0.9.90
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/compiler/htmlDocument.d.ts +2 -2
- package/dist/compiler/htmlDocument.js +2 -42
- package/dist/compiler/htmlTokens.d.ts +7 -0
- package/dist/compiler/htmlTokens.js +43 -0
- package/dist/generated/runtime-inline.js +1 -1
- package/dist/hyperframe.runtime.iife.js +69 -69
- package/dist/previewProxyBox.d.ts +1 -0
- package/dist/runtime/editing/gsapSet.js +2 -0
- package/dist/runtime/editing/patchTween.js +2 -1
- package/dist/runtime/editing/restoreAttributes.js +30 -3
- package/dist/runtime/editingDraft.d.ts +1 -5
- package/dist/runtime/editingDraft.js +111 -3
- package/dist/runtime/editingDraftEnd.d.ts +3 -3
- package/dist/runtime/editingDraftEnd.js +2 -2
- package/dist/runtime/editingGestureStart.d.ts +2 -0
- package/dist/runtime/editingGestureStart.js +2 -2
- package/dist/runtime/editingPort.d.ts +7 -0
- package/dist/runtime/editingPort.js +39 -5
- package/dist/runtime/runtimeAttributes.d.ts +4 -0
- package/dist/runtime/runtimeAttributes.js +17 -0
- package/dist/safePath.d.ts +7 -0
- package/dist/safePath.js +72 -1
- package/dist/studioPreviewMark.d.ts +3 -0
- package/dist/studioPreviewMark.js +5 -0
- package/dist/telemetryRedaction.js +15 -1
- package/dist/utils/richTextSanitize.js +30 -40
- package/package.json +8 -4
|
@@ -78,7 +78,8 @@ const OPAQUE_TAGS = new Set([
|
|
|
78
78
|
"MATH",
|
|
79
79
|
]);
|
|
80
80
|
/** Anything that reaches out of the stylesheet, in a property that should not. */
|
|
81
|
-
const UNSAFE_VALUE = /
|
|
81
|
+
const UNSAFE_VALUE = /javascript:|vbscript:|@import|<\//i;
|
|
82
|
+
const RESOURCE_FUNCTION = /(?:url|src|image|image-set|cross-fade|element|expression)\(/i;
|
|
82
83
|
const ELEMENT_NODE = 1;
|
|
83
84
|
const TEXT_NODE = 3;
|
|
84
85
|
export function isRichTextFormattingTag(tagName) {
|
|
@@ -92,7 +93,8 @@ export function isRichTextFormattingAttribute(name, value) {
|
|
|
92
93
|
export function isRichTextFormattingStyle(property, value) {
|
|
93
94
|
return (FORMATTING_STYLE_PROPS.has(property.toLowerCase()) &&
|
|
94
95
|
value.length > 0 &&
|
|
95
|
-
!UNSAFE_VALUE.test(value)
|
|
96
|
+
!UNSAFE_VALUE.test(value) &&
|
|
97
|
+
!RESOURCE_FUNCTION.test(withoutPlainStrings(value)));
|
|
96
98
|
}
|
|
97
99
|
function isElementNode(node) {
|
|
98
100
|
return node.nodeType === ELEMENT_NODE;
|
|
@@ -168,7 +170,7 @@ function stripAttributes(element) {
|
|
|
168
170
|
}
|
|
169
171
|
/** Keep only the allowlisted declarations, and only if their values are inert. */
|
|
170
172
|
function filterStyle(style) {
|
|
171
|
-
return splitDeclarations(style)
|
|
173
|
+
return (splitDeclarations(style) ?? [])
|
|
172
174
|
.map((declaration) => {
|
|
173
175
|
const colon = declaration.indexOf(":");
|
|
174
176
|
if (colon === -1)
|
|
@@ -182,45 +184,33 @@ function filterStyle(style) {
|
|
|
182
184
|
.filter((declaration) => declaration !== null)
|
|
183
185
|
.join("; ");
|
|
184
186
|
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
return depth + 1;
|
|
191
|
-
if (char === ")")
|
|
192
|
-
return Math.max(0, depth - 1);
|
|
193
|
-
return depth;
|
|
194
|
-
}
|
|
195
|
-
function isDeclarationSeparator(char, depth, quote) {
|
|
196
|
-
return char === ";" && depth === 0 && quote === null;
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Split on the semicolons that separate declarations, not the ones inside a
|
|
200
|
-
* value. `color: rgb(1, 2, 3)` is one declaration however many separators its
|
|
201
|
-
* value contains.
|
|
202
|
-
*/
|
|
187
|
+
const PLAIN_STRING = /"[^"\\\n\r\f]*"|'[^'\\\n\r\f]*'/g;
|
|
188
|
+
const withoutPlainStrings = (text) => text.replace(PLAIN_STRING, (string) => "_".repeat(string.length));
|
|
189
|
+
// Outside plain strings: an escape, a stray or broken quote, a comment, a bracket no formatting value needs.
|
|
190
|
+
const READ_UNLIKE_CSS = /[\\"'{}[\]]|\/\*/;
|
|
191
|
+
/** Declarations split where a browser splits them, or null for text this split could read differently from CSS. */
|
|
203
192
|
function splitDeclarations(style) {
|
|
193
|
+
const bare = withoutPlainStrings(style);
|
|
194
|
+
if (READ_UNLIKE_CSS.test(bare) || !bracketsCloseWithoutSemicolon(bare))
|
|
195
|
+
return null;
|
|
204
196
|
const declarations = [];
|
|
205
|
-
let
|
|
197
|
+
let start = 0;
|
|
198
|
+
for (let end = bare.indexOf(";"); end !== -1; end = bare.indexOf(";", start)) {
|
|
199
|
+
declarations.push(style.slice(start, end));
|
|
200
|
+
start = end + 1;
|
|
201
|
+
}
|
|
202
|
+
declarations.push(style.slice(start));
|
|
203
|
+
return declarations.filter((declaration) => declaration.trim());
|
|
204
|
+
}
|
|
205
|
+
function bracketsCloseWithoutSemicolon(bare) {
|
|
206
206
|
let depth = 0;
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
declarations.push(current);
|
|
215
|
-
current = "";
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
else if (quote === null) {
|
|
219
|
-
depth = nextParenthesisDepth(depth, char);
|
|
220
|
-
}
|
|
221
|
-
current += char;
|
|
207
|
+
for (const char of bare) {
|
|
208
|
+
if (char === "(")
|
|
209
|
+
depth++;
|
|
210
|
+
else if (char === ")")
|
|
211
|
+
depth--;
|
|
212
|
+
if (depth < 0 || (depth > 0 && char === ";"))
|
|
213
|
+
return false;
|
|
222
214
|
}
|
|
223
|
-
|
|
224
|
-
declarations.push(current);
|
|
225
|
-
return declarations;
|
|
215
|
+
return depth === 0;
|
|
226
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.90",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -377,6 +377,10 @@
|
|
|
377
377
|
"import": "./dist/compiler/compositionSizeLimit.js",
|
|
378
378
|
"types": "./dist/compiler/compositionSizeLimit.d.ts"
|
|
379
379
|
},
|
|
380
|
+
"./compiler/html-tokens": {
|
|
381
|
+
"import": "./dist/compiler/htmlTokens.js",
|
|
382
|
+
"types": "./dist/compiler/htmlTokens.d.ts"
|
|
383
|
+
},
|
|
380
384
|
"./compiler/html-document": {
|
|
381
385
|
"import": "./dist/compiler/htmlDocument.js",
|
|
382
386
|
"types": "./dist/compiler/htmlDocument.d.ts"
|
|
@@ -501,9 +505,9 @@
|
|
|
501
505
|
"linkedom": "^0.18.12",
|
|
502
506
|
"postcss": "^8.5.8",
|
|
503
507
|
"wawoff2": "^2.0.1",
|
|
504
|
-
"@hyperframes/lint": "0.9.
|
|
505
|
-
"@hyperframes/
|
|
506
|
-
"@hyperframes/
|
|
508
|
+
"@hyperframes/lint": "0.9.90",
|
|
509
|
+
"@hyperframes/studio-server": "0.9.90",
|
|
510
|
+
"@hyperframes/parsers": "0.9.90"
|
|
507
511
|
},
|
|
508
512
|
"devDependencies": {
|
|
509
513
|
"@fontsource/archivo-black": "^5.2.8",
|