@ng-prism/core 22.1.2 → 22.1.4
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.
|
@@ -301,6 +301,10 @@ export class PrismRendererComponent {
|
|
|
301
301
|
read: ViewContainerRef,
|
|
302
302
|
}, isSignal: true }] }] }); })();
|
|
303
303
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(PrismRendererComponent, { className: "PrismRendererComponent", filePath: "app/renderer/prism-renderer.component.ts", lineNumber: 180 }); })();
|
|
304
|
+
// SAFETY: `content` originates from `@Showcase({ variants: [{ content }] })`
|
|
305
|
+
// in developer-authored source code. It is trusted by ng-prism's threat model
|
|
306
|
+
// (see SECURITY.md). Sanitization would strip the Angular component/directive
|
|
307
|
+
// selectors that variant content is meant to project.
|
|
304
308
|
function parseContentToNodes(content) {
|
|
305
309
|
if (typeof content === 'string') {
|
|
306
310
|
return [htmlToNodes(content)];
|
|
@@ -313,10 +317,12 @@ function parseContentToNodes(content) {
|
|
|
313
317
|
if (selector === 'default')
|
|
314
318
|
continue;
|
|
315
319
|
const wrapper = document.createElement('div');
|
|
320
|
+
// SAFETY: trusted developer-authored HTML — see SECURITY.md.
|
|
316
321
|
wrapper.innerHTML = html;
|
|
317
322
|
const nodes = [];
|
|
318
323
|
for (const child of Array.from(wrapper.childNodes)) {
|
|
319
324
|
const el = document.createElement('div');
|
|
325
|
+
// SAFETY: trusted developer-authored HTML — see SECURITY.md.
|
|
320
326
|
el.innerHTML = child.outerHTML ?? child.textContent ?? '';
|
|
321
327
|
const projected = el.firstChild;
|
|
322
328
|
if (projected && projected instanceof Element) {
|
|
@@ -334,6 +340,8 @@ function parseContentToNodes(content) {
|
|
|
334
340
|
}
|
|
335
341
|
return result;
|
|
336
342
|
}
|
|
343
|
+
// SAFETY: see `parseContentToNodes` above and SECURITY.md — `html` is trusted
|
|
344
|
+
// developer-authored variant content from the `@Showcase` decorator.
|
|
337
345
|
function htmlToNodes(html) {
|
|
338
346
|
const wrapper = document.createElement('div');
|
|
339
347
|
wrapper.innerHTML = html;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snippet-generator.d.ts","sourceRoot":"","sources":["../../../src/app/renderer/snippet-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;CAC/B;AAwBD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,EAAE,EACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,gBAAgB,CAAC,EAAE,uBAAuB,GACzC,MAAM,
|
|
1
|
+
{"version":3,"file":"snippet-generator.d.ts","sourceRoot":"","sources":["../../../src/app/renderer/snippet-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAEvE,MAAM,WAAW,uBAAuB;IACtC,IAAI,CAAC,EAAE,MAAM,GAAG,aAAa,CAAC;CAC/B;AAwBD,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,SAAS,EAAE,EACnB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,EAClC,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,gBAAgB,CAAC,EAAE,uBAAuB,GACzC,MAAM,CA0ER"}
|
|
@@ -6,7 +6,7 @@ function pushAttribute(attributes, name, value) {
|
|
|
6
6
|
attributes.push(`${name}="${escapeAttrValue(value)}"`);
|
|
7
7
|
}
|
|
8
8
|
else if (typeof value === 'boolean') {
|
|
9
|
-
attributes.push(`[${name}]="
|
|
9
|
+
attributes.push(`[${name}]="${value}"`);
|
|
10
10
|
}
|
|
11
11
|
else if (typeof value === 'number') {
|
|
12
12
|
attributes.push(`[${name}]="${value}"`);
|
|
@@ -29,12 +29,16 @@ export function generateSnippet(selector, inputs, values, explicitKeys, content,
|
|
|
29
29
|
const value = values[input.name];
|
|
30
30
|
if (value === undefined)
|
|
31
31
|
continue;
|
|
32
|
-
if (typeof value === 'boolean' && !value)
|
|
33
|
-
continue;
|
|
34
32
|
if (input.defaultValue !== undefined &&
|
|
35
33
|
value === input.defaultValue &&
|
|
36
34
|
!explicitKeys?.has(input.name))
|
|
37
35
|
continue;
|
|
36
|
+
// Only a guess, and only sound when no default is known: a boolean input
|
|
37
|
+
// that defaults to `true` has to show its explicit `false`.
|
|
38
|
+
if (input.defaultValue === undefined &&
|
|
39
|
+
typeof value === 'boolean' &&
|
|
40
|
+
!value)
|
|
41
|
+
continue;
|
|
38
42
|
pushAttribute(attributes, input.name, value);
|
|
39
43
|
}
|
|
40
44
|
for (const [name, value] of Object.entries(values)) {
|
|
@@ -108,12 +112,16 @@ function generateDirectiveSnippet(selector, inputs, values, explicitKeys, conten
|
|
|
108
112
|
const value = values[input.name];
|
|
109
113
|
if (value === undefined)
|
|
110
114
|
continue;
|
|
111
|
-
if (typeof value === 'boolean' && !value)
|
|
112
|
-
continue;
|
|
113
115
|
if (input.defaultValue !== undefined &&
|
|
114
116
|
value === input.defaultValue &&
|
|
115
117
|
!explicitKeys?.has(input.name))
|
|
116
118
|
continue;
|
|
119
|
+
// Only a guess, and only sound when no default is known: a boolean input
|
|
120
|
+
// that defaults to `true` has to show its explicit `false`.
|
|
121
|
+
if (input.defaultValue === undefined &&
|
|
122
|
+
typeof value === 'boolean' &&
|
|
123
|
+
!value)
|
|
124
|
+
continue;
|
|
117
125
|
pushAttribute(attributes, input.name, value);
|
|
118
126
|
}
|
|
119
127
|
for (const [name, value] of Object.entries(values)) {
|
package/package.json
CHANGED