gyosjs 0.3.0 → 0.3.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/core/router/csp-html.d.ts +2 -0
- package/dist/core/router/csp-html.d.ts.map +1 -0
- package/dist/core/router/diff-nodes.d.ts.map +1 -1
- package/dist/core/router/router.d.ts.map +1 -1
- package/dist/gyos.auto.esm.js +261 -32
- package/dist/gyos.auto.esm.js.map +1 -1
- package/dist/gyos.auto.js +261 -32
- package/dist/gyos.auto.js.map +1 -1
- package/dist/gyos.auto.min.js +2 -2
- package/dist/gyos.csp.auto.esm.js +261 -32
- package/dist/gyos.csp.auto.esm.js.map +1 -1
- package/dist/gyos.csp.auto.js +261 -32
- package/dist/gyos.csp.auto.js.map +1 -1
- package/dist/gyos.csp.auto.min.js +2 -2
- package/dist/gyos.csp.esm.js +261 -32
- package/dist/gyos.csp.esm.js.map +1 -1
- package/dist/gyos.csp.js +261 -32
- package/dist/gyos.csp.js.map +1 -1
- package/dist/gyos.csp.min.js +2 -2
- package/dist/gyos.esm.js +261 -32
- package/dist/gyos.esm.js.map +1 -1
- package/dist/gyos.js +261 -32
- package/dist/gyos.js.map +1 -1
- package/dist/gyos.min.js +2 -2
- package/dist/runtime/csp-nonce.d.ts +1 -1
- package/dist/runtime/csp-nonce.d.ts.map +1 -1
- package/dist/template/structurals/transition-helpers.d.ts +1 -1
- package/dist/template/structurals/transition-helpers.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"csp-html.d.ts","sourceRoot":"","sources":["../../../src/core/router/csp-html.ts"],"names":[],"mappings":"AA6FA,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA0E1D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-nodes.d.ts","sourceRoot":"","sources":["../../../src/core/router/diff-nodes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diff-nodes.d.ts","sourceRoot":"","sources":["../../../src/core/router/diff-nodes.ts"],"names":[],"mappings":"AA4FA,wBAAsB,SAAS,CAC9B,YAAY,EAAE,OAAO,EAAE,EACvB,SAAS,EAAE,OAAO,EAAE,EACpB,SAAS,GAAE,WAA2B,EACtC,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,IAAI,CAAC,CA+Df"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/core/router/router.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,aAAa;IAC7B,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,UAAU,eAAe;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACzB,IAAI,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,eAAe,CAAC,EAAE,WAAW,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAgBD,UAAU,QAAQ;IACjB,IAAI,EAAE,MAAM,CAAC;CACb;AAiCD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAEtE;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,IAAI,CAErE;AAED,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CA2BzD;AA6DD,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAarD;AAoRD,iBAAe,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAoU5D;AAiKD,iBAAS,gBAAgB,IAAI,IAAI,CAsBhC;AAGD,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC"}
|
package/dist/gyos.auto.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* GyosJS v0.3.
|
|
2
|
+
* GyosJS v0.3.1
|
|
3
3
|
* (c) 2026
|
|
4
4
|
* @license MIT
|
|
5
5
|
*/
|
|
@@ -2262,32 +2262,24 @@ function applyTransitionStyles() {
|
|
|
2262
2262
|
* Handles:
|
|
2263
2263
|
* 1. Literal string: "fade" or "slide-down"
|
|
2264
2264
|
* 2. Expression with {}: "{transition}"
|
|
2265
|
-
* 3.
|
|
2265
|
+
* 3. Quoted literal kept for backwards compatibility: "'fade'"
|
|
2266
2266
|
*
|
|
2267
2267
|
* @param attrValue - The g-transition attribute value
|
|
2268
2268
|
* @param scope - Current scope for expression evaluation
|
|
2269
2269
|
* @returns The transition name (string)
|
|
2270
2270
|
*/
|
|
2271
2271
|
function parseTransitionName(attrValue, scope) {
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
}
|
|
2278
|
-
}
|
|
2279
|
-
// Try to evaluate as expression first (variable name)
|
|
2280
|
-
// If it fails or returns undefined, use as literal string
|
|
2281
|
-
try {
|
|
2282
|
-
const evaluated = evaluateExpression(attrValue, scope);
|
|
2283
|
-
if (evaluated !== undefined && evaluated !== null) {
|
|
2284
|
-
return evaluated;
|
|
2285
|
-
}
|
|
2272
|
+
const value = attrValue.trim();
|
|
2273
|
+
const expression = /^\{([\s\S]+)\}$/.exec(value);
|
|
2274
|
+
if (expression) {
|
|
2275
|
+
const evaluated = evaluateExpression(expression[1].trim(), scope);
|
|
2276
|
+
return evaluated == null ? '' : String(evaluated);
|
|
2286
2277
|
}
|
|
2287
|
-
|
|
2288
|
-
|
|
2278
|
+
if (value.length >= 2 && ((value.startsWith("'") && value.endsWith("'"))
|
|
2279
|
+
|| (value.startsWith('"') && value.endsWith('"')))) {
|
|
2280
|
+
return value.slice(1, -1);
|
|
2289
2281
|
}
|
|
2290
|
-
return
|
|
2282
|
+
return value;
|
|
2291
2283
|
}
|
|
2292
2284
|
/**
|
|
2293
2285
|
* Parse transition config from element's g-transition attribute
|
|
@@ -6756,7 +6748,7 @@ function hideTargetSpinner(spinner) {
|
|
|
6756
6748
|
}
|
|
6757
6749
|
|
|
6758
6750
|
let nonceSource;
|
|
6759
|
-
/** Configure the nonce used
|
|
6751
|
+
/** Configure the active document nonce used for scripts and styles during MPA navigation. */
|
|
6760
6752
|
function setCspNonce(source) {
|
|
6761
6753
|
nonceSource = source;
|
|
6762
6754
|
}
|
|
@@ -7328,9 +7320,33 @@ function handleScroll(url, trigger, savedScroll) {
|
|
|
7328
7320
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
|
7329
7321
|
}
|
|
7330
7322
|
|
|
7331
|
-
function
|
|
7332
|
-
return
|
|
7333
|
-
|
|
7323
|
+
function isNonceMeta(el) {
|
|
7324
|
+
return el.tagName === 'META' && el.getAttribute('name')?.toLowerCase() === 'csp-nonce';
|
|
7325
|
+
}
|
|
7326
|
+
function isStylesheetLink(el) {
|
|
7327
|
+
return el.tagName === 'LINK'
|
|
7328
|
+
&& (el.getAttribute('rel') || '').toLowerCase().split(/\s+/).includes('stylesheet');
|
|
7329
|
+
}
|
|
7330
|
+
function usesCspNonce(el) {
|
|
7331
|
+
return el.tagName === 'SCRIPT' || el.tagName === 'STYLE' || isStylesheetLink(el);
|
|
7332
|
+
}
|
|
7333
|
+
function serializeAttributes(el, context) {
|
|
7334
|
+
const attributes = new Map();
|
|
7335
|
+
Array.from(el.attributes).forEach(attr => {
|
|
7336
|
+
if (context.csp && usesCspNonce(el) && attr.name.toLowerCase() === 'nonce')
|
|
7337
|
+
return;
|
|
7338
|
+
if (context.csp && isNonceMeta(el) && attr.name.toLowerCase() === 'content')
|
|
7339
|
+
return;
|
|
7340
|
+
attributes.set(attr.name, attr.value);
|
|
7341
|
+
});
|
|
7342
|
+
if (context.csp && usesCspNonce(el) && context.activeNonce) {
|
|
7343
|
+
attributes.set('nonce', context.activeNonce);
|
|
7344
|
+
}
|
|
7345
|
+
if (context.csp && isNonceMeta(el) && context.activeNonce) {
|
|
7346
|
+
attributes.set('content', context.activeNonce);
|
|
7347
|
+
}
|
|
7348
|
+
return Array.from(attributes)
|
|
7349
|
+
.map(([name, value]) => `${name}=${value}`)
|
|
7334
7350
|
.sort()
|
|
7335
7351
|
.join('|');
|
|
7336
7352
|
}
|
|
@@ -7341,23 +7357,61 @@ function hashContent(content) {
|
|
|
7341
7357
|
}
|
|
7342
7358
|
return String(hash);
|
|
7343
7359
|
}
|
|
7344
|
-
function elementKey(el) {
|
|
7360
|
+
function elementKey(el, context) {
|
|
7345
7361
|
const tag = el.tagName.toLowerCase();
|
|
7346
7362
|
const content = tag === 'script' || tag === 'style' ? hashContent(el.textContent || '') : '';
|
|
7347
|
-
return `${tag}|${serializeAttributes(el)}|${content}`;
|
|
7363
|
+
return `${tag}|${serializeAttributes(el, context)}|${content}`;
|
|
7348
7364
|
}
|
|
7349
|
-
function keyedNodes(nodes) {
|
|
7365
|
+
function keyedNodes(nodes, context) {
|
|
7350
7366
|
const occurrences = new Map();
|
|
7351
7367
|
return nodes.map(node => {
|
|
7352
|
-
const baseKey = elementKey(node);
|
|
7368
|
+
const baseKey = elementKey(node, context);
|
|
7353
7369
|
const occurrence = occurrences.get(baseKey) || 0;
|
|
7354
7370
|
occurrences.set(baseKey, occurrence + 1);
|
|
7355
7371
|
return { key: `${baseKey}|${occurrence}`, node };
|
|
7356
7372
|
});
|
|
7357
7373
|
}
|
|
7374
|
+
function canInsertNode(node, context) {
|
|
7375
|
+
if (!context.csp)
|
|
7376
|
+
return true;
|
|
7377
|
+
if (isNonceMeta(node))
|
|
7378
|
+
return Boolean(context.activeNonce);
|
|
7379
|
+
if (node.tagName === 'STYLE')
|
|
7380
|
+
return Boolean(context.activeNonce);
|
|
7381
|
+
if (node.tagName === 'SCRIPT' && !node.hasAttribute('src'))
|
|
7382
|
+
return Boolean(context.activeNonce);
|
|
7383
|
+
return true;
|
|
7384
|
+
}
|
|
7385
|
+
function reconcileCspAttributes(node, context) {
|
|
7386
|
+
if (!context.csp)
|
|
7387
|
+
return;
|
|
7388
|
+
if (isNonceMeta(node)) {
|
|
7389
|
+
if (context.activeNonce)
|
|
7390
|
+
node.setAttribute('content', context.activeNonce);
|
|
7391
|
+
return;
|
|
7392
|
+
}
|
|
7393
|
+
if (!usesCspNonce(node))
|
|
7394
|
+
return;
|
|
7395
|
+
node.removeAttribute('nonce');
|
|
7396
|
+
if (context.activeNonce)
|
|
7397
|
+
node.setAttribute('nonce', context.activeNonce);
|
|
7398
|
+
}
|
|
7399
|
+
function warnSkippedNode(node) {
|
|
7400
|
+
if (node.tagName === 'STYLE') {
|
|
7401
|
+
console.warn('[GyosJS CSP] Skipped an inline MPA style because no active document nonce is configured.');
|
|
7402
|
+
}
|
|
7403
|
+
else if (node.tagName === 'SCRIPT' && !node.hasAttribute('src')) {
|
|
7404
|
+
console.warn('[GyosJS CSP] Skipped an inline MPA script because no active document nonce is configured.');
|
|
7405
|
+
}
|
|
7406
|
+
}
|
|
7358
7407
|
async function diffNodes(currentNodes, nextNodes, container = document.head, signal) {
|
|
7359
|
-
const
|
|
7360
|
-
const
|
|
7408
|
+
const csp = expressionRuntimeMode() === 'csp';
|
|
7409
|
+
const context = {
|
|
7410
|
+
csp,
|
|
7411
|
+
activeNonce: csp ? resolveCspNonce() : undefined
|
|
7412
|
+
};
|
|
7413
|
+
const current = keyedNodes(currentNodes, context);
|
|
7414
|
+
const next = keyedNodes(nextNodes, context);
|
|
7361
7415
|
const currentKeys = new Set(current.map(item => item.key));
|
|
7362
7416
|
const nextKeys = new Set(next.map(item => item.key));
|
|
7363
7417
|
// Remove nodes that are not in the new head
|
|
@@ -7371,6 +7425,20 @@ async function diffNodes(currentNodes, nextNodes, container = document.head, sig
|
|
|
7371
7425
|
if (signal?.aborted)
|
|
7372
7426
|
return;
|
|
7373
7427
|
if (!currentKeys.has(key)) {
|
|
7428
|
+
if (!canInsertNode(node, context)) {
|
|
7429
|
+
warnSkippedNode(node);
|
|
7430
|
+
continue;
|
|
7431
|
+
}
|
|
7432
|
+
if (node.tagName === 'STYLE') {
|
|
7433
|
+
const style = document.createElement('style');
|
|
7434
|
+
Array.from(node.attributes).forEach(attr => style.setAttribute(attr.name, attr.value));
|
|
7435
|
+
reconcileCspAttributes(style, context);
|
|
7436
|
+
// CSP checks inline styles as their CSS text is attached. Set the active
|
|
7437
|
+
// nonce first so a response nonce never produces a transient violation.
|
|
7438
|
+
style.textContent = node.textContent || '';
|
|
7439
|
+
container.appendChild(style);
|
|
7440
|
+
continue;
|
|
7441
|
+
}
|
|
7374
7442
|
if (node.tagName === 'SCRIPT') {
|
|
7375
7443
|
const originalScript = node;
|
|
7376
7444
|
const executionKey = getScriptExecutionKey(originalScript);
|
|
@@ -7381,6 +7449,7 @@ async function diffNodes(currentNodes, nextNodes, container = document.head, sig
|
|
|
7381
7449
|
}
|
|
7382
7450
|
const script = document.createElement('script');
|
|
7383
7451
|
Array.from(node.attributes).forEach(attr => script.setAttribute(attr.name, attr.value));
|
|
7452
|
+
reconcileCspAttributes(script, context);
|
|
7384
7453
|
script.textContent = node.hasAttribute('g-script-wrap')
|
|
7385
7454
|
? wrapScriptExecution(node.textContent || '')
|
|
7386
7455
|
: node.textContent || '';
|
|
@@ -7390,9 +7459,166 @@ async function diffNodes(currentNodes, nextNodes, container = document.head, sig
|
|
|
7390
7459
|
await completion;
|
|
7391
7460
|
continue;
|
|
7392
7461
|
}
|
|
7393
|
-
|
|
7462
|
+
const imported = document.importNode(node, true);
|
|
7463
|
+
reconcileCspAttributes(imported, context);
|
|
7464
|
+
container.appendChild(imported);
|
|
7465
|
+
}
|
|
7466
|
+
}
|
|
7467
|
+
}
|
|
7468
|
+
|
|
7469
|
+
const RAW_TEXT_ELEMENTS = new Set(['iframe', 'noembed', 'noframes', 'plaintext', 'script', 'textarea', 'title', 'xmp']);
|
|
7470
|
+
function escapeAttribute(value) {
|
|
7471
|
+
return value.replace(/&/g, '&').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>');
|
|
7472
|
+
}
|
|
7473
|
+
function findTagEnd(html, start) {
|
|
7474
|
+
let quote = '';
|
|
7475
|
+
for (let index = start; index < html.length; index += 1) {
|
|
7476
|
+
const character = html[index];
|
|
7477
|
+
if (quote) {
|
|
7478
|
+
if (character === quote)
|
|
7479
|
+
quote = '';
|
|
7480
|
+
continue;
|
|
7481
|
+
}
|
|
7482
|
+
if (character === '"' || character === "'") {
|
|
7483
|
+
quote = character;
|
|
7484
|
+
continue;
|
|
7485
|
+
}
|
|
7486
|
+
if (character === '>')
|
|
7487
|
+
return index + 1;
|
|
7488
|
+
}
|
|
7489
|
+
return html.length;
|
|
7490
|
+
}
|
|
7491
|
+
function findClosingTag(html, lowerHtml, name, start) {
|
|
7492
|
+
const needle = `</${name}`;
|
|
7493
|
+
let position = lowerHtml.indexOf(needle, start);
|
|
7494
|
+
while (position !== -1) {
|
|
7495
|
+
const boundary = lowerHtml[position + needle.length];
|
|
7496
|
+
if (boundary === '>' || /\s/.test(boundary || '')) {
|
|
7497
|
+
return {
|
|
7498
|
+
start: position,
|
|
7499
|
+
end: findTagEnd(html, position + needle.length)
|
|
7500
|
+
};
|
|
7501
|
+
}
|
|
7502
|
+
position = lowerHtml.indexOf(needle, position + needle.length);
|
|
7503
|
+
}
|
|
7504
|
+
return null;
|
|
7505
|
+
}
|
|
7506
|
+
function removeNonceAttribute(openingTag) {
|
|
7507
|
+
const prefix = /^<\s*style\b/i.exec(openingTag);
|
|
7508
|
+
if (!prefix)
|
|
7509
|
+
return openingTag;
|
|
7510
|
+
let output = prefix[0];
|
|
7511
|
+
let cursor = prefix[0].length;
|
|
7512
|
+
const limit = openingTag.length - 1;
|
|
7513
|
+
while (cursor < limit) {
|
|
7514
|
+
const attributeStart = cursor;
|
|
7515
|
+
while (cursor < limit && /\s/.test(openingTag[cursor]))
|
|
7516
|
+
cursor += 1;
|
|
7517
|
+
if (cursor >= limit || openingTag[cursor] === '>') {
|
|
7518
|
+
output += openingTag.slice(attributeStart, cursor);
|
|
7519
|
+
break;
|
|
7520
|
+
}
|
|
7521
|
+
const nameStart = cursor;
|
|
7522
|
+
while (cursor < limit && !/[\s=/>]/.test(openingTag[cursor]))
|
|
7523
|
+
cursor += 1;
|
|
7524
|
+
if (cursor === nameStart) {
|
|
7525
|
+
output += openingTag.slice(attributeStart, cursor + 1);
|
|
7526
|
+
cursor += 1;
|
|
7527
|
+
continue;
|
|
7528
|
+
}
|
|
7529
|
+
const name = openingTag.slice(nameStart, cursor).toLowerCase();
|
|
7530
|
+
while (cursor < limit && /\s/.test(openingTag[cursor]))
|
|
7531
|
+
cursor += 1;
|
|
7532
|
+
if (openingTag[cursor] === '=') {
|
|
7533
|
+
cursor += 1;
|
|
7534
|
+
while (cursor < limit && /\s/.test(openingTag[cursor]))
|
|
7535
|
+
cursor += 1;
|
|
7536
|
+
const quote = openingTag[cursor] === '"' || openingTag[cursor] === "'" ? openingTag[cursor] : '';
|
|
7537
|
+
if (quote) {
|
|
7538
|
+
cursor += 1;
|
|
7539
|
+
while (cursor < limit && openingTag[cursor] !== quote)
|
|
7540
|
+
cursor += 1;
|
|
7541
|
+
if (openingTag[cursor] === quote)
|
|
7542
|
+
cursor += 1;
|
|
7543
|
+
}
|
|
7544
|
+
else {
|
|
7545
|
+
while (cursor < limit && !/[\s>]/.test(openingTag[cursor]))
|
|
7546
|
+
cursor += 1;
|
|
7547
|
+
}
|
|
7548
|
+
}
|
|
7549
|
+
if (name !== 'nonce')
|
|
7550
|
+
output += openingTag.slice(attributeStart, cursor);
|
|
7551
|
+
}
|
|
7552
|
+
return output + openingTag.slice(limit);
|
|
7553
|
+
}
|
|
7554
|
+
function withNonce(openingTag, nonce) {
|
|
7555
|
+
const withoutNonce = removeNonceAttribute(openingTag);
|
|
7556
|
+
return `${withoutNonce.slice(0, -1)} nonce="${escapeAttribute(nonce)}">`;
|
|
7557
|
+
}
|
|
7558
|
+
function prepareNavigationHtml(html) {
|
|
7559
|
+
if (expressionRuntimeMode() !== 'csp')
|
|
7560
|
+
return html;
|
|
7561
|
+
const activeNonce = resolveCspNonce();
|
|
7562
|
+
const lowerHtml = html.toLowerCase();
|
|
7563
|
+
let output = '';
|
|
7564
|
+
let cursor = 0;
|
|
7565
|
+
let skippedStyles = 0;
|
|
7566
|
+
while (cursor < html.length) {
|
|
7567
|
+
const tagStart = html.indexOf('<', cursor);
|
|
7568
|
+
if (tagStart === -1) {
|
|
7569
|
+
output += html.slice(cursor);
|
|
7570
|
+
break;
|
|
7571
|
+
}
|
|
7572
|
+
output += html.slice(cursor, tagStart);
|
|
7573
|
+
if (html.startsWith('<!--', tagStart)) {
|
|
7574
|
+
const commentEnd = html.indexOf('-->', tagStart + 4);
|
|
7575
|
+
const end = commentEnd === -1 ? html.length : commentEnd + 3;
|
|
7576
|
+
output += html.slice(tagStart, end);
|
|
7577
|
+
cursor = end;
|
|
7578
|
+
continue;
|
|
7579
|
+
}
|
|
7580
|
+
const tagEnd = findTagEnd(html, tagStart + 1);
|
|
7581
|
+
const openingTag = html.slice(tagStart, tagEnd);
|
|
7582
|
+
const match = /^<\s*(\/?)\s*([a-z][\w:-]*)/i.exec(openingTag);
|
|
7583
|
+
if (!match || match[1]) {
|
|
7584
|
+
output += openingTag;
|
|
7585
|
+
cursor = tagEnd;
|
|
7586
|
+
continue;
|
|
7587
|
+
}
|
|
7588
|
+
const name = match[2].toLowerCase();
|
|
7589
|
+
if (name === 'plaintext') {
|
|
7590
|
+
output += html.slice(tagStart);
|
|
7591
|
+
break;
|
|
7592
|
+
}
|
|
7593
|
+
if (name === 'style' || name === 'noscript' || RAW_TEXT_ELEMENTS.has(name)) {
|
|
7594
|
+
const closingTag = findClosingTag(html, lowerHtml, name, tagEnd);
|
|
7595
|
+
const blockEnd = closingTag?.end ?? html.length;
|
|
7596
|
+
if (name === 'noscript') {
|
|
7597
|
+
cursor = blockEnd;
|
|
7598
|
+
continue;
|
|
7599
|
+
}
|
|
7600
|
+
if (name === 'style') {
|
|
7601
|
+
if (!activeNonce) {
|
|
7602
|
+
skippedStyles += 1;
|
|
7603
|
+
cursor = blockEnd;
|
|
7604
|
+
continue;
|
|
7605
|
+
}
|
|
7606
|
+
output += withNonce(openingTag, activeNonce);
|
|
7607
|
+
output += html.slice(tagEnd, blockEnd);
|
|
7608
|
+
cursor = blockEnd;
|
|
7609
|
+
continue;
|
|
7610
|
+
}
|
|
7611
|
+
output += html.slice(tagStart, blockEnd);
|
|
7612
|
+
cursor = blockEnd;
|
|
7613
|
+
continue;
|
|
7394
7614
|
}
|
|
7615
|
+
output += openingTag;
|
|
7616
|
+
cursor = tagEnd;
|
|
7617
|
+
}
|
|
7618
|
+
if (skippedStyles > 0) {
|
|
7619
|
+
console.warn(`[GyosJS CSP] Skipped ${skippedStyles} inline MPA style${skippedStyles === 1 ? '' : 's'} because no active document nonce is configured.`);
|
|
7395
7620
|
}
|
|
7621
|
+
return output;
|
|
7396
7622
|
}
|
|
7397
7623
|
|
|
7398
7624
|
/**
|
|
@@ -7458,7 +7684,10 @@ function stripInertFallbackContent(root) {
|
|
|
7458
7684
|
root.querySelectorAll('noscript').forEach(element => element.remove());
|
|
7459
7685
|
}
|
|
7460
7686
|
function parseNavigationDocument(html) {
|
|
7461
|
-
|
|
7687
|
+
// Chromium applies the active page CSP while DOMParser creates response
|
|
7688
|
+
// styles. Reconcile their nonce before parsing to avoid transient violations;
|
|
7689
|
+
// diffNodes repeats the check before insertion into the live document.
|
|
7690
|
+
const doc = new DOMParser().parseFromString(prepareNavigationHtml(html), 'text/html');
|
|
7462
7691
|
// DOMParser disables scripting and parses noscript children as active markup.
|
|
7463
7692
|
// A boosted page runs with scripting enabled, so those fallbacks must stay inert.
|
|
7464
7693
|
stripInertFallbackContent(doc);
|
|
@@ -8294,7 +8523,7 @@ const Gyos = {
|
|
|
8294
8523
|
portalCreate,
|
|
8295
8524
|
portalDestroy,
|
|
8296
8525
|
setCspNonce,
|
|
8297
|
-
version: '0.3.
|
|
8526
|
+
version: '0.3.1'
|
|
8298
8527
|
};
|
|
8299
8528
|
|
|
8300
8529
|
const standardExpressionRuntime = {
|