securemark 0.289.6 → 0.290.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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.289.6 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.290.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
2
2
  (function webpackUniversalModuleDefinition(root, factory) {
3
3
  if(typeof exports === 'object' && typeof module === 'object')
4
4
  module.exports = factory(require("Prism"), require("DOMPurify"));
@@ -322,250 +322,6 @@ __exportStar(__webpack_require__(1311), exports);
322
322
 
323
323
  /***/ },
324
324
 
325
- /***/ 8663
326
- (__unused_webpack_module, exports) {
327
-
328
- "use strict";
329
-
330
-
331
- Object.defineProperty(exports, "__esModule", ({
332
- value: true
333
- }));
334
- exports.Clock = void 0;
335
- const BASE = 32;
336
- const DIGIT = Math.log2(BASE);
337
- const MASK = BASE - 1;
338
- const empty = Symbol('empty');
339
- class Clock {
340
- // Capacity is rounded up to multiples of 32.
341
- constructor(capacity,
342
- // ヒット率99%で平均100bitの走査となるためこれを極端に超えない走査数に制限
343
- limit = BASE * 10) {
344
- this.capacity = capacity;
345
- this.limit = limit;
346
- this.dict = new Map();
347
- this.keys = [];
348
- this.values = [];
349
- this.hand = 0;
350
- this.$length = 0;
351
- this.initial = 1;
352
- this.capacity = ((capacity - 1 | MASK) >>> 0) + 1;
353
- this.refs = new Int32Array(this.capacity >>> DIGIT);
354
- }
355
- get length() {
356
- return this.$length;
357
- }
358
- get size() {
359
- return this.$length;
360
- }
361
- mark(index) {
362
- const i = index >>> DIGIT;
363
- const before = this.refs[i];
364
- const after = before | 1 << (index & MASK);
365
- if (after === before) return;
366
- this.refs[i] = after;
367
- }
368
- unmark(index) {
369
- const i = index >>> DIGIT;
370
- const before = this.refs[i];
371
- const after = before & ~(1 << (index & MASK));
372
- if (after === before) return;
373
- this.refs[i] = after;
374
- }
375
- locate(hand, key, value) {
376
- const {
377
- capacity,
378
- dict,
379
- keys,
380
- values
381
- } = this;
382
- this.$length === capacity || this.initial === 0 && values[hand] !== empty ? dict.delete(keys[hand]) : ++this.$length;
383
- dict.set(key, hand);
384
- keys[hand] = key;
385
- values[hand] = value;
386
- this.hand = ++hand === capacity ? this.initial = 0 : hand;
387
- }
388
- add(key, value) {
389
- const {
390
- capacity,
391
- limit,
392
- refs
393
- } = this;
394
- for (let {
395
- hand
396
- } = this, i = hand >>> DIGIT, r = hand & MASK, c = 0;;) {
397
- const b = refs[i];
398
- if (b >>> r === ~0 >>> r && c < limit) {
399
- const d = BASE - r;
400
- c += d;
401
- hand += d;
402
- refs[i] = b & (1 << r) - 1;
403
- r = 0;
404
- if (hand < capacity) {
405
- ++i;
406
- } else {
407
- hand -= capacity;
408
- i = 0;
409
- }
410
- continue;
411
- }
412
- const l = c < limit ? search(b, r) : r;
413
- if (l !== r) {
414
- hand += l - r;
415
- refs[i] = b & ~((1 << l) - 1 >>> r << r);
416
- }
417
- this.locate(hand, key, value);
418
- return hand;
419
- }
420
- }
421
- put(key, value) {
422
- const index = this.dict.get(key);
423
- if (index === undefined) return this.add(key, value);
424
- this.values[index] = value;
425
- return index;
426
- }
427
- set(key, value) {
428
- this.put(key, value);
429
- return this;
430
- }
431
- get(key) {
432
- const index = this.dict.get(key);
433
- if (index === undefined) return;
434
- this.mark(index);
435
- return this.values[index];
436
- }
437
- has(key) {
438
- return this.dict.has(key);
439
- }
440
- delete(key) {
441
- const index = this.dict.get(key);
442
- if (index === undefined) return false;
443
- // 末尾と削除対象を交換して削除する。
444
- // 次の挿入の前に次の削除が行われると交換できないが稀なため対処しない。
445
- const {
446
- hand,
447
- dict,
448
- keys,
449
- values,
450
- refs
451
- } = this;
452
- dict.delete(key);
453
- --this.$length;
454
- const k = keys[index] = keys[hand];
455
- const v = values[index] = values[hand];
456
- keys[hand] = undefined;
457
- values[hand] = empty;
458
- if (index !== hand && v !== empty) {
459
- dict.set(k, index);
460
- (refs[hand >>> DIGIT] & 1 << (hand & MASK)) === 0 ? this.unmark(index) : this.mark(index);
461
- }
462
- this.unmark(hand);
463
- return true;
464
- }
465
- clear() {
466
- this.dict = new Map();
467
- this.keys = [];
468
- this.values = [];
469
- this.refs.fill(0);
470
- this.hand = 0;
471
- this.$length = 0;
472
- this.initial = 1;
473
- }
474
- *[Symbol.iterator]() {
475
- const {
476
- keys,
477
- values
478
- } = this;
479
- for (const index of this.dict.values()) {
480
- yield [keys[index], values[index]];
481
- }
482
- }
483
- }
484
- exports.Clock = Clock;
485
- function search(b, r) {
486
- for (let l = r;; ++l) {
487
- if ((b & 1 << l) === 0) return l;
488
- }
489
- }
490
- function bsearch(b, r) {
491
- const n = ~b >>> r << r >>> 0;
492
- const l = potision(0x05f66a47 * (n & -n) >>> 27);
493
- return l;
494
- }
495
- //const potisions = new Uint8Array([
496
- // 0, 1, 2, 26, 23, 3, 15, 27, 24, 21, 19, 4, 12, 16, 28, 6, 31, 25, 22, 14, 20, 18, 11, 5, 30, 13, 17, 10, 29, 9, 8, 7,
497
- //]);
498
- function potision(n) {
499
- switch (n) {
500
- case 0:
501
- return 0;
502
- case 1:
503
- return 1;
504
- case 2:
505
- return 2;
506
- case 3:
507
- return 26;
508
- case 4:
509
- return 23;
510
- case 5:
511
- return 3;
512
- case 6:
513
- return 15;
514
- case 7:
515
- return 27;
516
- case 8:
517
- return 24;
518
- case 9:
519
- return 21;
520
- case 10:
521
- return 19;
522
- case 11:
523
- return 4;
524
- case 12:
525
- return 12;
526
- case 13:
527
- return 16;
528
- case 14:
529
- return 28;
530
- case 15:
531
- return 6;
532
- case 16:
533
- return 31;
534
- case 17:
535
- return 25;
536
- case 18:
537
- return 22;
538
- case 19:
539
- return 14;
540
- case 20:
541
- return 20;
542
- case 21:
543
- return 18;
544
- case 22:
545
- return 11;
546
- case 23:
547
- return 5;
548
- case 24:
549
- return 30;
550
- case 25:
551
- return 13;
552
- case 26:
553
- return 17;
554
- case 27:
555
- return 10;
556
- case 28:
557
- return 29;
558
- case 29:
559
- return 9;
560
- case 30:
561
- return 8;
562
- default:
563
- return 7;
564
- }
565
- }
566
-
567
- /***/ },
568
-
569
325
  /***/ 1934
570
326
  (__unused_webpack_module, exports) {
571
327
 
@@ -3241,8 +2997,8 @@ function close(parser, closer, optional, backtracks) {
3241
2997
  }
3242
2998
  exports.close = close;
3243
2999
  const statesize = 2;
3244
- function getBacktrack(context, backtracks, source, length) {
3245
- for (const backtrack of backtracks) {
3000
+ function getBacktrack(context, backtracks, source, length = 1) {
3001
+ if (length > 0) for (const backtrack of backtracks) {
3246
3002
  if (backtrack & 1) {
3247
3003
  const {
3248
3004
  backtracks = {},
@@ -3260,7 +3016,7 @@ function getBacktrack(context, backtracks, source, length) {
3260
3016
  }
3261
3017
  exports.getBacktrack = getBacktrack;
3262
3018
  function setBacktrack(context, backtracks, position, length = 1) {
3263
- for (const backtrack of backtracks) {
3019
+ if (length > 0) for (const backtrack of backtracks) {
3264
3020
  if (backtrack & 2) {
3265
3021
  const {
3266
3022
  backtracks = {},
@@ -5724,22 +5480,6 @@ function format(list) {
5724
5480
 
5725
5481
  /***/ },
5726
5482
 
5727
- /***/ 8669
5728
- (__unused_webpack_module, exports) {
5729
-
5730
- "use strict";
5731
-
5732
-
5733
- Object.defineProperty(exports, "__esModule", ({
5734
- value: true
5735
- }));
5736
- exports.CmdRegExp = void 0;
5737
- exports.CmdRegExp = {
5738
- Error: /\x07/g
5739
- };
5740
-
5741
- /***/ },
5742
-
5743
5483
  /***/ 3009
5744
5484
  (__unused_webpack_module, exports, __webpack_require__) {
5745
5485
 
@@ -6209,7 +5949,7 @@ const dom_1 = __webpack_require__(394);
6209
5949
  exports.code = (0, combinator_1.validate)(({
6210
5950
  source,
6211
5951
  context
6212
- }) => source[0] === '`' && !(0, combinator_1.getBacktrack)(context, [1 | 8 /* Backtrack.bracket */], source, source.length - 1), (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?)(?:((?<!`)\1(?!`))|$|\n)/, ([whole,, body, closer]) => ({
5952
+ }) => source[0] === '`' && !(0, combinator_1.getBacktrack)(context, [1 | 8 /* Backtrack.bracket */], source), (0, combinator_1.match)(/^(`+)(?!`)([^\n]*?)(?:((?<!`)\1(?!`))|$|\n)/, ([whole,, body, closer]) => ({
6213
5953
  source,
6214
5954
  context
6215
5955
  }) => closer ? [[(0, dom_1.html)('code', {
@@ -6380,18 +6120,19 @@ exports.index = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(32 /*
6380
6120
  class: 'index',
6381
6121
  href: el.id ? `#${el.id}` : undefined
6382
6122
  })])));
6383
- exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|', (0, combinator_1.surround)((0, source_1.str)(/^\|(?!\\?\s)/), (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']')), /^(?=])/, false, ([as, bs], rest, {
6384
- recent = []
6385
- }) => {
6123
+ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|', (0, combinator_1.surround)((0, source_1.str)(/^\|(?!\\?\s)/), (0, visibility_1.tightStart)((0, combinator_1.some)((0, combinator_1.union)([inline_1.inline]), ']')), /^(?=])/, false, (_, rest, context) => {
6124
+ //context.offset ??= 0;
6125
+ //context.offset += rest.length;
6386
6126
  const sig = (0, parser_1.eval)(parser({
6387
- source: recent[1],
6388
- context: {}
6127
+ source: context.recent[1],
6128
+ context
6389
6129
  }), []).join('');
6390
- const index = sig.includes("\u0007" /* Command.Error */) ? undefined : (0, indexee_1.identity)('index', undefined, sig)?.slice(7);
6391
- return index ? [[(0, dom_1.html)('span', {
6130
+ //context.offset -= rest.length;
6131
+ const index = (0, indexee_1.identity)('index', undefined, sig)?.slice(7);
6132
+ return [[(0, dom_1.html)('span', {
6392
6133
  class: 'indexer',
6393
6134
  'data-index': index
6394
- })], rest] : [(0, array_1.unshift)(as, bs), rest];
6135
+ })], rest];
6395
6136
  }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6396
6137
  function dataindex(ns) {
6397
6138
  if (ns.length === 0) return;
@@ -6651,7 +6392,6 @@ const source_1 = __webpack_require__(8745);
6651
6392
  const visibility_1 = __webpack_require__(6364);
6652
6393
  const util_1 = __webpack_require__(4992);
6653
6394
  const memoize_1 = __webpack_require__(6925);
6654
- const clock_1 = __webpack_require__(8663);
6655
6395
  const array_1 = __webpack_require__(6876);
6656
6396
  const dom_1 = __webpack_require__(394);
6657
6397
  const tags = Object.freeze(['bdo', 'bdi']);
@@ -6662,9 +6402,11 @@ const attrspecs = {
6662
6402
  };
6663
6403
  Object.setPrototypeOf(attrspecs, null);
6664
6404
  Object.values(attrspecs).forEach(o => Object.setPrototypeOf(o, null));
6665
- exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/i, (0, combinator_1.union)([(0, combinator_1.focus)(/^<wbr[^\S\n]*>/i, () => [[(0, dom_1.html)('wbr')], '']), (0, combinator_1.surround)(
6405
+ exports.html = (0, combinator_1.lazy)(() => (0, combinator_1.validate)(/^<[a-z]+(?=[^\S\n]|>)/i, (0, combinator_1.union)([(0, combinator_1.surround)(
6406
+ // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6407
+ (0, source_1.str)(/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, source_1.str)(/^[^\S\n]*>/), true, ([as, bs = [], cs], rest) => as[0].slice(1) === 'wbr' && bs.length === 0 ? [[(0, dom_1.html)(as[0].slice(1))], rest] : [[elem(as[0].slice(1), (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [])], rest], undefined, [3 | 8 /* Backtrack.bracket */]), (0, combinator_1.match)(new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true, undefined, undefined, [3 | 8 /* Backtrack.bracket */]), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)((0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', `</${tag}>`), [[(0, visibility_1.blankWith)('\n', `</${tag}>`), 3]]), true))]))), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => tag, new Map())), (0, combinator_1.surround)(
6666
6408
  // https://html.spec.whatwg.org/multipage/syntax.html#void-elements
6667
- (0, source_1.str)(/^<(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, source_1.str)(/^[^\S\n]*>/), true, ([as, bs = [], cs], rest) => [[elem(as[0].slice(1), (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [])], rest], undefined, [3 | 8 /* Backtrack.bracket */]), (0, combinator_1.match)(new RegExp(String.raw`^<(${TAGS.join('|')})(?=[^\S\n]|>)`), (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true, undefined, undefined, [3 | 8 /* Backtrack.bracket */]), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)((0, combinator_1.open)(/^\n?/, (0, combinator_1.some)(inline_1.inline, (0, visibility_1.blankWith)('\n', `</${tag}>`), [[(0, visibility_1.blankWith)('\n', `</${tag}>`), 3]]), true))]))), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => tag, new Map())), (0, combinator_1.match)(/^<([a-z]+)(?=[^\S\n]|>)/i, (0, memoize_1.memoize)(([, tag]) => (0, combinator_1.surround)((0, combinator_1.surround)((0, source_1.str)(`<${tag}`), (0, combinator_1.some)(exports.attribute), (0, source_1.str)(/^[^\S\n]*>/), true, undefined, undefined, [3 | 8 /* Backtrack.bracket */]), (0, combinator_1.precedence)(3, (0, combinator_1.recursion)(4 /* Recursion.inline */, (0, combinator_1.subsequence)([(0, combinator_1.focus)(/^[^\S\n]*\n/, (0, combinator_1.some)(inline_1.inline)), (0, combinator_1.some)(inline_1.inline, `</${tag}>`, [[`</${tag}>`, 3]])]))), (0, source_1.str)(`</${tag}>`), true, ([as, bs = [], cs], rest) => [[elem(tag, as, bs, cs)], rest], ([as, bs = []], rest) => [[elem(tag, as, bs, [])], rest]), ([, tag]) => tag, new clock_1.Clock(10000)))])));
6409
+ (0, source_1.str)(/^<[a-z]+(?=[^\S\n]|>)/i), (0, combinator_1.some)((0, combinator_1.union)([exports.attribute])), (0, source_1.str)(/^[^\S\n]*>/), true, ([as, bs = [], cs], rest) => [[elem(as[0].slice(1), (0, array_1.push)((0, array_1.unshift)(as, bs), cs), [], [])], rest], undefined, [3 | 8 /* Backtrack.bracket */])])));
6668
6410
  exports.attribute = (0, combinator_1.union)([(0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="[^"\n]*")?(?=[^\S\n]|>)/i)]);
6669
6411
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Element
6670
6412
  // [...document.querySelectorAll('tbody > tr > td:first-child')].map(el => el.textContent.slice(1, -1))
@@ -6720,13 +6462,15 @@ exports.htmlentity = exports.unsafehtmlentity = void 0;
6720
6462
  const combinator_1 = __webpack_require__(3484);
6721
6463
  const util_1 = __webpack_require__(4992);
6722
6464
  const dom_1 = __webpack_require__(394);
6723
- exports.unsafehtmlentity = (0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&[0-9A-Za-z]{1,99};/, ({
6465
+ exports.unsafehtmlentity = (0, combinator_1.validate)('&', (0, combinator_1.focus)(/^&[0-9A-Za-z]{1,99};/,
6466
+ //({ source }) => [[parser(source) ?? `${Command.Error}${source}`], '']));
6467
+ ({
6724
6468
  source
6725
- }) => [[parser(source) ?? `${"\u0007" /* Command.Error */}${source}`], '']));
6726
- exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([text]) => [text[0] === "\u0007" /* Command.Error */ ? (0, dom_1.html)('span', {
6469
+ }) => [[parser(source) ?? source], '']));
6470
+ exports.htmlentity = (0, combinator_1.fmap)((0, combinator_1.union)([exports.unsafehtmlentity]), ([text]) => [text.length === 1 || text[0] !== '&' ? text : (0, dom_1.html)('span', {
6727
6471
  class: 'invalid',
6728
6472
  ...(0, util_1.invalid)('htmlentity', 'syntax', 'Invalid HTML entity')
6729
- }, text.slice(1)) : text]);
6473
+ }, text)]);
6730
6474
  const parser = (el => entity => {
6731
6475
  if (entity === '&NewLine;') return ' ';
6732
6476
  el.innerHTML = entity;
@@ -6822,14 +6566,21 @@ exports.uri = (0, combinator_1.union)([(0, combinator_1.open)(/^[^\S\n]+/, (0, s
6822
6566
  exports.option = (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+nofollow(?=[^\S\n]|})/), () => [` rel="nofollow"`]), (0, source_1.str)(/^[^\S\n]+[a-z]+(?:-[a-z]+)*(?:="(?:\\[^\n]|[^\\\n"])*")?(?=[^\S\n]|})/), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[^\s{}]+/), opt => [` \\${opt.slice(1)}`])]);
6823
6567
  function parse(content, params, context) {
6824
6568
  const INSECURE_URI = params.shift();
6825
- const uri = new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
6569
+ let uri;
6570
+ try {
6571
+ uri = new url_1.ReadonlyURL(resolve(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
6572
+ } catch {}
6826
6573
  const el = elem(INSECURE_URI, content, uri, context.host?.origin || location.origin);
6827
6574
  return el.classList.contains('invalid') ? el : (0, dom_1.define)(el, (0, html_1.attributes)('link', [], optspec, params));
6828
6575
  }
6829
6576
  function elem(INSECURE_URI, content, uri, origin) {
6830
6577
  let type;
6831
6578
  let message;
6832
- switch (uri.protocol) {
6579
+ switch (uri?.protocol) {
6580
+ case undefined:
6581
+ type = 'argument';
6582
+ message = 'Invalid URI';
6583
+ break;
6833
6584
  case 'http:':
6834
6585
  case 'https:':
6835
6586
  switch (true) {
@@ -6863,10 +6614,13 @@ function elem(INSECURE_URI, content, uri, origin) {
6863
6614
  message = 'Invalid content';
6864
6615
  }
6865
6616
  break;
6617
+ default:
6618
+ type = 'argument';
6619
+ message = 'Invalid protocol';
6866
6620
  }
6867
6621
  return (0, dom_1.html)('a', {
6868
6622
  class: 'invalid',
6869
- ...(0, util_1.invalid)('link', type ??= 'argument', message ??= 'Invalid protocol')
6623
+ ...(0, util_1.invalid)('link', type, message)
6870
6624
  }, content.length === 0 ? INSECURE_URI : content);
6871
6625
  }
6872
6626
  function resolve(uri, host, source) {
@@ -6977,7 +6731,6 @@ Object.defineProperty(exports, "__esModule", ({
6977
6731
  value: true
6978
6732
  }));
6979
6733
  exports.linemedia = exports.media = void 0;
6980
- const context_1 = __webpack_require__(8669);
6981
6734
  const combinator_1 = __webpack_require__(3484);
6982
6735
  const link_1 = __webpack_require__(3628);
6983
6736
  const html_1 = __webpack_require__(5013);
@@ -6996,15 +6749,19 @@ const optspec = {
6996
6749
  Object.setPrototypeOf(optspec, null);
6997
6750
  exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* State.media */, false, (0, combinator_1.validate)(['![', '!{'], (0, combinator_1.creation)(10, (0, combinator_1.open)('!', (0, combinator_1.bind)((0, combinator_1.verify)((0, combinator_1.fmap)((0, combinator_1.tails)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']')), ']', true, ([, ns = []], rest, context) => context.linebreak === undefined ? [ns, rest] : undefined, undefined, [3 | 4 /* Backtrack.escbracket */])), (0, combinator_1.dup)((0, combinator_1.surround)(/^{(?![{}])/, (0, combinator_1.inits)([link_1.uri, (0, combinator_1.some)(option)]), /^[^\S\n]*}/, false, undefined, undefined, [3 | 64 /* Backtrack.link */]))]), ([as, bs]) => bs ? [[as.join('').trim() || as.join('')], bs] : [[''], as]), ([[text]]) => text === '' || text.trim() !== ''), ([[text], params], rest, context) => {
6998
6751
  const INSECURE_URI = params.shift();
6999
- const url = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
6752
+ // altが空だとエラーが見えないため埋める。
6753
+ text ||= INSECURE_URI;
6754
+ let uri;
6755
+ try {
6756
+ uri = new url_1.ReadonlyURL((0, link_1.resolve)(INSECURE_URI, context.host ?? location, context.url ?? context.host ?? location), context.host?.href || location.href);
6757
+ } catch {}
7000
6758
  let cache;
7001
- const el = false || (cache = context.caches?.media?.get(url.href)?.cloneNode(true)) || (0, dom_1.html)('img', {
6759
+ const el = false || uri && (cache = context.caches?.media?.get(uri.href)?.cloneNode(true)) || (0, dom_1.html)('img', {
7002
6760
  class: 'media',
7003
- 'data-src': url.source,
7004
- alt: text
6761
+ 'data-src': uri?.source
7005
6762
  });
7006
- cache?.hasAttribute('alt') && cache.setAttribute('alt', text);
7007
- if (!sanitize(el, url, text)) return [[el], rest];
6763
+ el.setAttribute('alt', text);
6764
+ if (!sanitize(el, uri)) return [[el], rest];
7008
6765
  (0, dom_1.define)(el, (0, html_1.attributes)('media', (0, array_1.push)([], el.classList), optspec, params));
7009
6766
  // Awaiting the generic support for attr().
7010
6767
  if (el.hasAttribute('aspect-ratio')) {
@@ -7023,34 +6780,35 @@ exports.media = (0, combinator_1.lazy)(() => (0, combinator_1.constraint)(4 /* S
7023
6780
  exports.linemedia = (0, combinator_1.surround)(source_1.linebreak, (0, combinator_1.union)([exports.media]), /^(?=[^\S\n]*(?:$|\n))/);
7024
6781
  const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ')'), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), ']'), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, bracket, source_1.txt]), '}'), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.some)((0, combinator_1.union)([htmlentity_1.unsafehtmlentity, source_1.txt]), '"')), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */])])));
7025
6782
  const option = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*x[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` width="${opt.slice(1).split('x')[0]}"`, ` height="${opt.slice(1).split('x')[1]}"`]), (0, combinator_1.fmap)((0, source_1.str)(/^[^\S\n]+[1-9][0-9]*:[1-9][0-9]*(?=[^\S\n]|})/), ([opt]) => [` aspect-ratio="${opt.slice(1).split(':').join('/')}"`]), link_1.option]));
7026
- function sanitize(target, uri, alt) {
7027
- switch (uri.protocol) {
6783
+ function sanitize(target, uri) {
6784
+ let type;
6785
+ let message;
6786
+ switch (uri?.protocol) {
6787
+ case undefined:
6788
+ type = 'argument';
6789
+ message = 'Invalid URI';
6790
+ break;
7028
6791
  case 'http:':
7029
6792
  case 'https:':
7030
- if (/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) {
7031
- (0, dom_1.define)(target, {
7032
- class: 'invalid',
7033
- ...(0, util_1.invalid)('media', 'argument', 'Dot-segments cannot be used in media paths; use subresource paths instead')
7034
- });
7035
- return false;
7036
- }
6793
+ if (!/\/\.\.?(?:\/|$)/.test('/' + uri.source.slice(0, uri.source.search(/[?#]|$/)))) return true;
6794
+ type = 'argument';
6795
+ message = 'Dot-segments cannot be used in media paths; use subresource paths instead';
7037
6796
  break;
7038
6797
  default:
7039
- (0, dom_1.define)(target, {
7040
- class: 'invalid',
7041
- ...(0, util_1.invalid)('media', 'argument', 'Invalid protocol')
7042
- });
7043
- return false;
6798
+ type = 'argument';
6799
+ message = 'Invalid protocol';
7044
6800
  }
7045
- if (alt.includes("\u0007" /* Command.Error */)) {
7046
- (0, dom_1.define)(target, {
7047
- class: 'invalid',
7048
- alt: target.getAttribute('alt')?.replace(context_1.CmdRegExp.Error, ''),
7049
- ...(0, util_1.invalid)('media', 'argument', `Cannot use invalid HTML entitiy "${alt.match(/&[0-9A-Za-z]+;/)[0]}"`)
7050
- });
7051
- return false;
7052
- }
7053
- return true;
6801
+ //else {
6802
+ // target.setAttribute('alt', alt.replace(CmdRegExp.Error, ''));
6803
+ // type = 'argument';
6804
+ // message = `Invalid HTML entitiy "${alt.match(/&[0-9A-Za-z]+;/)![0]}"`;
6805
+ //}
6806
+ (0, dom_1.define)(target, {
6807
+ 'data-src': null,
6808
+ class: 'invalid',
6809
+ ...(0, util_1.invalid)('link', type, message)
6810
+ });
6811
+ return false;
7054
6812
  }
7055
6813
 
7056
6814
  /***/ },
@@ -7137,47 +6895,37 @@ Object.defineProperty(exports, "__esModule", ({
7137
6895
  value: true
7138
6896
  }));
7139
6897
  exports.ruby = void 0;
7140
- const context_1 = __webpack_require__(8669);
7141
6898
  const parser_1 = __webpack_require__(605);
7142
6899
  const combinator_1 = __webpack_require__(3484);
7143
6900
  const htmlentity_1 = __webpack_require__(470);
7144
6901
  const source_1 = __webpack_require__(8745);
7145
6902
  const visibility_1 = __webpack_require__(6364);
7146
- const util_1 = __webpack_require__(4992);
7147
6903
  const array_1 = __webpack_require__(6876);
7148
6904
  const dom_1 = __webpack_require__(394);
7149
- exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.inits)([(0, combinator_1.dup)((0, combinator_1.surround)('[', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}<>"\n])+/), ']', false, ([, [source]], rest, context) => {
7150
- const ns = (0, parser_1.eval)(text({
7151
- source,
7152
- context
7153
- }), [undefined])[0];
6905
+ exports.ruby = (0, combinator_1.lazy)(() => (0, combinator_1.bind)((0, combinator_1.inits)([(0, combinator_1.dup)((0, combinator_1.surround)('[', rtext, ']', false, ([, ns], rest) => {
7154
6906
  ns && ns.at(-1) === '' && ns.pop();
7155
- return ns && (0, visibility_1.isTightNodeStart)(ns) ? [ns, rest] : undefined;
7156
- }, undefined, [3 | 32 /* Backtrack.ruby */ | 1, 64 /* Backtrack.link */, 1 | 8 /* Backtrack.bracket */])), (0, combinator_1.dup)((0, combinator_1.surround)('(', (0, source_1.str)(/^(?:\\[^\n]|[^\\[\](){}<>"\n])+/), ')', false, ([, [source]], rest, context) => {
7157
- const ns = (0, parser_1.eval)(text({
7158
- source,
7159
- context
7160
- }), [undefined])[0];
7161
- return ns && [ns, rest];
7162
- }, undefined, [3 | 32 /* Backtrack.ruby */ | 1, 64 /* Backtrack.link */, 1 | 8 /* Backtrack.bracket */]))]), ([texts, rubies], rest, context) => {
6907
+ return (0, visibility_1.isTightNodeStart)(ns) ? [ns, rest] : undefined;
6908
+ }, undefined, [3 | 32 /* Backtrack.ruby */ | 1, 64 /* Backtrack.link */, 1 | 8 /* Backtrack.bracket */])), (0, combinator_1.dup)((0, combinator_1.surround)('(', rtext, ')', false, undefined, undefined, [3 | 32 /* Backtrack.ruby */ | 1, 64 /* Backtrack.link */, 1 | 8 /* Backtrack.bracket */]))]), ([texts, rubies], rest, context) => {
7163
6909
  if (rubies === undefined) {
7164
6910
  return void (0, combinator_1.setBacktrack)(context, [2 | 32 /* Backtrack.ruby */], context.recent.reduce((a, b) => a + b.length, 0));
7165
6911
  }
7166
6912
  switch (true) {
7167
6913
  case rubies.length <= texts.length:
7168
- return [[(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))], rest];
6914
+ return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)(texts.reduce((acc, _, i) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))], rest];
7169
6915
  case texts.length === 1 && [...texts[0]].length >= rubies.length:
7170
- return [[(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))], rest];
6916
+ return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)([...texts[0]].reduce((acc, _, i, texts) => (0, array_1.push)(acc, (0, array_1.unshift)([texts[i]], i < rubies.length && rubies[i] ? [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies[i]), (0, dom_1.html)('rp', ')')] : [(0, dom_1.html)('rt')])), [])))], rest];
7171
6917
  default:
7172
- return [[(0, dom_1.html)('ruby', attributes(texts, rubies), (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))], rest];
6918
+ return [[(0, dom_1.html)('ruby', (0, dom_1.defrag)((0, array_1.unshift)([texts.join(' ')], [(0, dom_1.html)('rp', '('), (0, dom_1.html)('rt', rubies.join(' ').trim()), (0, dom_1.html)('rp', ')')])))], rest];
7173
6919
  }
7174
6920
  }));
7175
- const text = ({
6921
+ const rtext = ({
7176
6922
  source,
7177
6923
  context
7178
6924
  }) => {
7179
6925
  const acc = [''];
6926
+ let state = false;
7180
6927
  while (source !== '') {
6928
+ if (!/^(?:\\[^\n]|[^\\[\](){}<>"\n])/.test(source)) break;
7181
6929
  switch (source[0]) {
7182
6930
  // @ts-expect-error
7183
6931
  case '&':
@@ -7189,6 +6937,7 @@ const text = ({
7189
6937
  if (result) {
7190
6938
  acc[acc.length - 1] += (0, parser_1.eval)(result)[0];
7191
6939
  source = (0, parser_1.exec)(result, source.slice(1));
6940
+ state ||= acc.at(-1).trimStart() !== '';
7192
6941
  continue;
7193
6942
  }
7194
6943
  // fallthrough
@@ -7206,26 +6955,27 @@ const text = ({
7206
6955
  });
7207
6956
  acc[acc.length - 1] += (0, parser_1.eval)(result)[0] ?? source.slice(0, source.length - (0, parser_1.exec)(result).length);
7208
6957
  source = (0, parser_1.exec)(result);
6958
+ state ||= acc.at(-1).trimStart() !== '';
7209
6959
  continue;
7210
6960
  }
7211
6961
  }
7212
6962
  }
7213
- return acc.join('').trimStart() ? [[acc], ''] : undefined;
6963
+ return state ? [acc, source] : undefined;
7214
6964
  };
7215
- function attributes(texts, rubies) {
7216
- let attrs;
7217
- for (const ss of [texts, rubies]) {
7218
- for (let i = 0; i < ss.length; ++i) {
7219
- if (!ss[i].includes("\u0007" /* Command.Error */)) continue;
7220
- ss[i] = ss[i].replace(context_1.CmdRegExp.Error, '');
7221
- attrs ??= {
7222
- class: 'invalid',
7223
- ...(0, util_1.invalid)('ruby', ss === texts ? 'content' : 'argument', 'Invalid HTML entity')
7224
- };
7225
- }
7226
- }
7227
- return attrs ?? {};
7228
- }
6965
+ //function attributes(texts: string[], rubies: string[]): Record<string, string> {
6966
+ // let attrs: Record<string, string> | undefined;
6967
+ // for (const ss of [texts, rubies]) {
6968
+ // for (let i = 0; i < ss.length; ++i) {
6969
+ // if (!ss[i].includes(Command.Error)) continue;
6970
+ // ss[i] = ss[i].replace(CmdRegExp.Error, '');
6971
+ // attrs ??= {
6972
+ // class: 'invalid',
6973
+ // ...invalid('ruby', ss === texts ? 'content' : 'argument', 'Invalid HTML entity'),
6974
+ // };
6975
+ // }
6976
+ // }
6977
+ // return attrs ?? {};
6978
+ //}
7229
6979
 
7230
6980
  /***/ },
7231
6981
 
@@ -7281,11 +7031,14 @@ Object.defineProperty(exports, "__esModule", ({
7281
7031
  exports.template = void 0;
7282
7032
  const combinator_1 = __webpack_require__(3484);
7283
7033
  const source_1 = __webpack_require__(8745);
7034
+ const array_1 = __webpack_require__(6876);
7284
7035
  const dom_1 = __webpack_require__(394);
7285
- exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)('{{', (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), '}}', true, ([, ns = []], rest, context) => context.linebreak === undefined ? [[(0, dom_1.html)('span', {
7036
+ exports.template = (0, combinator_1.lazy)(() => (0, combinator_1.surround)((0, source_1.str)('{{'), (0, combinator_1.precedence)(1, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}}'), true, ([as, bs = [], cs], rest) => [[(0, dom_1.html)('span', {
7286
7037
  class: 'template'
7287
- }, `{{${ns.join('')}}}`)], rest] : undefined, undefined, [3 | 16 /* Backtrack.doublebracket */, 1 | 8 /* Backtrack.bracket */]));
7288
- const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, '"'))), (0, source_1.str)('"'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */])]));
7038
+ }, (0, dom_1.defrag)((0, array_1.push)((0, array_1.unshift)(as, bs), cs)))], rest], undefined, [3 | 16 /* Backtrack.doublebracket */, 3 | 4 /* Backtrack.escbracket */]));
7039
+ const bracket = (0, combinator_1.lazy)(() => (0, combinator_1.union)([(0, combinator_1.surround)((0, source_1.str)('('), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ')')), (0, source_1.str)(')'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('['), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), ']')), (0, source_1.str)(']'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('{'), (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)((0, combinator_1.union)([bracket, source_1.escsource]), '}')), (0, source_1.str)('}'), true, undefined, () => [[], ''], [3 | 4 /* Backtrack.escbracket */]), (0, combinator_1.surround)((0, source_1.str)('"'), (0, combinator_1.precedence)(2, (0, combinator_1.recursion)(6 /* Recursion.terminal */, (0, combinator_1.some)(source_1.escsource, '"', [['"', 2, false]]))), (0, source_1.str)('"'), true, ([as, bs = [], cs], rest, {
7040
+ linebreak = 0
7041
+ }) => linebreak > rest.length ? [(0, array_1.unshift)(as, bs), cs[0] + rest] : [(0, array_1.push)((0, array_1.unshift)(as, bs), cs), rest], ([as, bs = []], rest) => [(0, array_1.unshift)(as, bs), rest], [3 | 4 /* Backtrack.escbracket */])]));
7289
7042
 
7290
7043
  /***/ },
7291
7044
 
@@ -7724,6 +7477,7 @@ Object.defineProperty(exports, "__esModule", ({
7724
7477
  exports.escsource = void 0;
7725
7478
  const combinator_1 = __webpack_require__(3484);
7726
7479
  const text_1 = __webpack_require__(5655);
7480
+ const dom_1 = __webpack_require__(394);
7727
7481
  const delimiter = /[\s\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/;
7728
7482
  const escsource = ({
7729
7483
  source,
@@ -7756,7 +7510,7 @@ const escsource = ({
7756
7510
  }
7757
7511
  case '\n':
7758
7512
  context.linebreak ??= source.length;
7759
- return [[source[0]], source.slice(1)];
7513
+ return [[(0, dom_1.html)('br')], source.slice(1)];
7760
7514
  default:
7761
7515
  const b = source[0].trimStart() === '';
7762
7516
  const i = b ? source.search(text_1.nonWhitespace) : 1;
@@ -7911,6 +7665,7 @@ Object.defineProperty(exports, "__esModule", ({
7911
7665
  exports.unescsource = void 0;
7912
7666
  const combinator_1 = __webpack_require__(3484);
7913
7667
  const text_1 = __webpack_require__(5655);
7668
+ const dom_1 = __webpack_require__(394);
7914
7669
  const unescsource = ({
7915
7670
  source,
7916
7671
  context
@@ -7933,7 +7688,7 @@ const unescsource = ({
7933
7688
  return [[source.slice(1, 2)], source.slice(2)];
7934
7689
  case '\n':
7935
7690
  context.linebreak ??= source.length;
7936
- return [[source[0]], source.slice(1)];
7691
+ return [[(0, dom_1.html)('br')], source.slice(1)];
7937
7692
  default:
7938
7693
  const b = source[0].trimStart() === '';
7939
7694
  const i = b || (0, text_1.isAlphanumeric)(source[0]) ? source.search(b ? text_1.nonWhitespace : text_1.nonAlphanumeric) || 1 : 1;