securemark 0.290.1 → 0.290.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.290.2
4
+
5
+ - Refactoring.
6
+
3
7
  ## 0.290.1
4
8
 
5
9
  - Refactoring.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! securemark v0.290.1 https://github.com/falsandtru/securemark | (c) 2017, falsandtru | UNLICENSED License */
1
+ /*! securemark v0.290.2 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"));
@@ -6129,10 +6129,10 @@ exports.signature = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('|',
6129
6129
  }), []).join('');
6130
6130
  //context.offset -= rest.length;
6131
6131
  const index = (0, indexee_1.identity)('index', undefined, sig)?.slice(7);
6132
- return [[(0, dom_1.html)('span', {
6132
+ return index ? [[(0, dom_1.html)('span', {
6133
6133
  class: 'indexer',
6134
6134
  'data-index': index
6135
- })], rest];
6135
+ })], rest] : undefined;
6136
6136
  }, ([as, bs], rest) => [(0, array_1.unshift)(as, bs), rest])));
6137
6137
  function dataindex(ns) {
6138
6138
  if (ns.length === 0) return;
@@ -6532,7 +6532,7 @@ exports.italic = (0, combinator_1.lazy)(() => (0, combinator_1.validate)('///',
6532
6532
  Object.defineProperty(exports, "__esModule", ({
6533
6533
  value: true
6534
6534
  }));
6535
- exports.resolve = exports.option = exports.uri = exports.unsafelink = exports.linemedialink = exports.medialink = exports.textlink = void 0;
6535
+ exports.decode = exports.resolve = exports.option = exports.uri = exports.unsafelink = exports.linemedialink = exports.medialink = exports.textlink = void 0;
6536
6536
  const combinator_1 = __webpack_require__(3484);
6537
6537
  const inline_1 = __webpack_require__(7973);
6538
6538
  const html_1 = __webpack_require__(5013);
@@ -6640,7 +6640,6 @@ function resolve(uri, host, source) {
6640
6640
  }
6641
6641
  exports.resolve = resolve;
6642
6642
  function decode(uri) {
6643
- if (!uri.includes('%')) return uri;
6644
6643
  const origin = uri.match(/^[a-z](?:[-.](?=[0-9a-z])|[0-9a-z])*:(?:\/{0,2}[^/?#\s]+|\/\/(?=[/]))/i)?.[0] ?? '';
6645
6644
  try {
6646
6645
  let path = decodeURI(uri.slice(origin.length));
@@ -6652,6 +6651,7 @@ function decode(uri) {
6652
6651
  return uri.replace(/\s+/g, encodeURI);
6653
6652
  }
6654
6653
  }
6654
+ exports.decode = decode;
6655
6655
 
6656
6656
  /***/ },
6657
6657
 
@@ -6750,7 +6750,7 @@ Object.setPrototypeOf(optspec, null);
6750
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) => {
6751
6751
  const INSECURE_URI = params.shift();
6752
6752
  // altが空だとエラーが見えないため埋める。
6753
- text ||= INSECURE_URI;
6753
+ text ||= (0, link_1.decode)(INSECURE_URI);
6754
6754
  let uri;
6755
6755
  try {
6756
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "securemark",
3
- "version": "0.290.1",
3
+ "version": "0.290.2",
4
4
  "description": "Secure markdown renderer working on browsers for user input data.",
5
5
  "private": false,
6
6
  "homepage": "https://github.com/falsandtru/securemark",
@@ -49,7 +49,9 @@ export const signature: IndexParser.SignatureParser = lazy(() => validate('|', s
49
49
  const sig = eval(parser({ source: context.recent![1], context }), []).join('');
50
50
  //context.offset -= rest.length;
51
51
  const index = identity('index', undefined, sig)?.slice(7);
52
- return [[html('span', { class: 'indexer', 'data-index': index })], rest];
52
+ return index
53
+ ? [[html('span', { class: 'indexer', 'data-index': index })], rest]
54
+ : undefined;
53
55
  },
54
56
  ([as, bs], rest) => [unshift(as, bs), rest])));
55
57
 
@@ -226,8 +226,7 @@ export function resolve(uri: string, host: URL | Location, source: URL | Locatio
226
226
  }
227
227
  }
228
228
 
229
- function decode(uri: string): string {
230
- if (!uri.includes('%')) return uri;
229
+ export function decode(uri: string): string {
231
230
  const origin = uri.match(/^[a-z](?:[-.](?=[0-9a-z])|[0-9a-z])*:(?:\/{0,2}[^/?#\s]+|\/\/(?=[/]))/i)?.[0] ?? '';
232
231
  try {
233
232
  let path = decodeURI(uri.slice(origin.length));
@@ -1,7 +1,7 @@
1
1
  import { MediaParser } from '../inline';
2
2
  import { State, Recursion, Backtrack } from '../context';
3
3
  import { union, inits, tails, some, creation, recursion, precedence, constraint, validate, verify, surround, open, dup, lazy, fmap, bind } from '../../combinator';
4
- import { unsafelink, uri, option as linkoption, resolve } from './link';
4
+ import { unsafelink, uri, option as linkoption, resolve, decode } from './link';
5
5
  import { attributes } from './html';
6
6
  import { unsafehtmlentity } from './htmlentity';
7
7
  import { txt, linebreak, str } from '../source';
@@ -51,7 +51,7 @@ export const media: MediaParser = lazy(() => constraint(State.media, false, vali
51
51
  assert(INSECURE_URI === INSECURE_URI.trim());
52
52
  assert(!INSECURE_URI.match(/\s/));
53
53
  // altが空だとエラーが見えないため埋める。
54
- text ||= INSECURE_URI;
54
+ text ||= decode(INSECURE_URI);
55
55
  let uri: ReadonlyURL | undefined;
56
56
  try {
57
57
  uri = new ReadonlyURL(