@openclaw/matrix 2026.6.11 → 2026.6.34

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.
Files changed (50) hide show
  1. package/dist/api.js +1 -1
  2. package/dist/{approval-handler.runtime-CK5HedmU.js → approval-handler.runtime-NM2VK9st.js} +1 -1
  3. package/dist/{channel-Y_HGdzpZ.js → channel-DBu5bvBi.js} +4 -3
  4. package/dist/channel-plugin-api.js +1 -1
  5. package/dist/{monitor-BpvP2_nj.js → monitor-BLr_siHV.js} +7 -4
  6. package/node_modules/linkify-it/README.md +3 -4
  7. package/node_modules/linkify-it/build/index.cjs.js +44 -41
  8. package/node_modules/linkify-it/index.mjs +10 -11
  9. package/node_modules/linkify-it/lib/re.mjs +34 -30
  10. package/node_modules/linkify-it/package.json +10 -15
  11. package/node_modules/markdown-it/dist/index.cjs.js +3652 -5378
  12. package/node_modules/markdown-it/dist/index.cjs.js.map +1 -0
  13. package/node_modules/markdown-it/dist/markdown-it.js +1399 -4479
  14. package/node_modules/markdown-it/dist/markdown-it.js.map +1 -0
  15. package/node_modules/markdown-it/dist/markdown-it.min.js +3 -2
  16. package/node_modules/markdown-it/dist/markdown-it.min.js.map +1 -0
  17. package/node_modules/markdown-it/lib/common/html_re.mjs +9 -9
  18. package/node_modules/markdown-it/lib/common/utils.mjs +2 -11
  19. package/node_modules/markdown-it/lib/parser_block.mjs +9 -9
  20. package/node_modules/markdown-it/lib/parser_core.mjs +7 -7
  21. package/node_modules/markdown-it/lib/parser_inline.mjs +16 -16
  22. package/node_modules/markdown-it/lib/renderer.mjs +2 -2
  23. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +6 -6
  24. package/node_modules/markdown-it/lib/rules_block/code.mjs +2 -2
  25. package/node_modules/markdown-it/lib/rules_block/fence.mjs +4 -4
  26. package/node_modules/markdown-it/lib/rules_block/heading.mjs +7 -7
  27. package/node_modules/markdown-it/lib/rules_block/hr.mjs +2 -2
  28. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +6 -6
  29. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +8 -8
  30. package/node_modules/markdown-it/lib/rules_block/list.mjs +6 -6
  31. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +5 -5
  32. package/node_modules/markdown-it/lib/rules_block/reference.mjs +1 -1
  33. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +6 -6
  34. package/node_modules/markdown-it/lib/rules_block/table.mjs +4 -4
  35. package/node_modules/markdown-it/lib/rules_core/block.mjs +3 -3
  36. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +15 -15
  37. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +2 -2
  38. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +17 -17
  39. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +2 -2
  40. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +8 -8
  41. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +7 -7
  42. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +15 -1
  43. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +1 -1
  44. package/node_modules/markdown-it/lib/rules_inline/link.mjs +1 -1
  45. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +2 -2
  46. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +10 -10
  47. package/node_modules/markdown-it/lib/token.mjs +12 -12
  48. package/node_modules/markdown-it/package.json +25 -34
  49. package/npm-shrinkwrap.json +12 -12
  50. package/package.json +5 -5
package/dist/api.js CHANGED
@@ -2,7 +2,7 @@ import { a as resolveMatrixDefaultOrOnlyAccountId, i as resolveMatrixChannelConf
2
2
  import { n as listMatrixEnvAccountIds, r as resolveMatrixEnvAccountToken, t as getMatrixScopedEnvVarNames } from "./env-vars-KzaYveuy.js";
3
3
  import { a as resolveMatrixCredentialsPath, c as resolveMatrixLegacyFlatStoreRoot, i as resolveMatrixCredentialsFilename, l as sanitizeMatrixPathSegment, n as resolveMatrixAccountStorageRoot, o as resolveMatrixHomeserverKey, r as resolveMatrixCredentialsDir, s as resolveMatrixLegacyFlatStoragePaths, t as hashMatrixAccessToken } from "./storage-paths-BWo_ZEMC.js";
4
4
  import { n as matrixSetupAdapter, t as createMatrixSetupWizardProxy } from "./setup-core-Ub_idsu1.js";
5
- import { t as matrixPlugin } from "./channel-Y_HGdzpZ.js";
5
+ import { t as matrixPlugin } from "./channel-DBu5bvBi.js";
6
6
  import { d as setMatrixThreadBindingIdleTimeoutBySessionKey, n as getMatrixThreadBindingManager, p as setMatrixThreadBindingMaxAgeBySessionKey, s as resetMatrixThreadBindingsForTests } from "./thread-bindings-shared-CKnY4LSd.js";
7
7
  import { n as matrixOnboardingAdapter } from "./setup-surface-CXenmuMm.js";
8
8
  import { t as createMatrixThreadBindingManager } from "./thread-bindings-DuoPRata.js";
@@ -1,5 +1,5 @@
1
1
  import { g as resolveMatrixAccount } from "./setup-core-Ub_idsu1.js";
2
- import { _ as shouldHandleMatrixApprovalRequest, g as isMatrixAnyApprovalClientEnabled } from "./channel-Y_HGdzpZ.js";
2
+ import { _ as shouldHandleMatrixApprovalRequest, g as isMatrixAnyApprovalClientEnabled } from "./channel-DBu5bvBi.js";
3
3
  import { a as resolveMatrixTargetIdentity } from "./target-ids-B-5aQxwn.js";
4
4
  import { a as sendMessageMatrix, i as reactMatrixMessage, p as repairMatrixDirectRooms, s as sendSingleTextMessageMatrix } from "./send-eoayPB_l.js";
5
5
  import { a as unregisterMatrixApprovalReactionTarget, n as listMatrixApprovalReactionBindings, r as registerMatrixApprovalReactionTarget, t as buildMatrixApprovalReactionHint } from "./approval-reactions-BRGQgOu2.js";
@@ -21,7 +21,7 @@ import { createChannelDirectoryAdapter, createResolvedDirectoryEntriesLister, cr
21
21
  import { createLazyRuntimeNamedExport } from "openclaw/plugin-sdk/lazy-runtime";
22
22
  import { buildProbeChannelStatusSummary, collectStatusIssuesFromLastError, createComputedAccountStatusAdapter, createDefaultChannelRuntimeState } from "openclaw/plugin-sdk/status-helpers";
23
23
  import { normalizeLowercaseStringOrEmpty, normalizeOptionalString, normalizeOptionalStringifiedId } from "openclaw/plugin-sdk/string-coerce-runtime";
24
- import { chunkTextForOutbound } from "openclaw/plugin-sdk/text-chunking";
24
+ import { chunkTextForOutbound, sanitizeAssistantVisibleText } from "openclaw/plugin-sdk/text-chunking";
25
25
  import { ToolAuthorizationError, createActionGate, readPositiveIntegerParam, readStringParam } from "openclaw/plugin-sdk/channel-actions";
26
26
  import { extractToolSend } from "openclaw/plugin-sdk/tool-send";
27
27
  import { Type } from "typebox";
@@ -594,7 +594,7 @@ const matrixNativeApprovalCapability = createApproverRestrictedNativeApprovalCap
594
594
  accountId,
595
595
  request
596
596
  }),
597
- load: async () => (await import("./approval-handler.runtime-CK5HedmU.js")).matrixApprovalNativeRuntime
597
+ load: async () => (await import("./approval-handler.runtime-NM2VK9st.js")).matrixApprovalNativeRuntime
598
598
  })
599
599
  });
600
600
  const splitMatrixApprovalCapability = splitChannelApprovalCapability(matrixNativeApprovalCapability);
@@ -1103,6 +1103,7 @@ const matrixChannelOutbound = {
1103
1103
  chunker: chunkTextForOutbound,
1104
1104
  chunkerMode: "markdown",
1105
1105
  textChunkLimit: 4e3,
1106
+ sanitizeText: ({ text }) => sanitizeAssistantVisibleText(text),
1106
1107
  deliveryCapabilities: { durableFinal: {
1107
1108
  text: true,
1108
1109
  media: true,
@@ -1322,7 +1323,7 @@ const matrixPlugin = createChatChannelPlugin({
1322
1323
  await previousLock;
1323
1324
  let monitorMatrixProvider;
1324
1325
  try {
1325
- monitorMatrixProvider = (await import("./monitor-BpvP2_nj.js")).monitorMatrixProvider;
1326
+ monitorMatrixProvider = (await import("./monitor-BLr_siHV.js")).monitorMatrixProvider;
1326
1327
  } finally {
1327
1328
  releaseLock();
1328
1329
  }
@@ -1,2 +1,2 @@
1
- import { t as matrixPlugin } from "./channel-Y_HGdzpZ.js";
1
+ import { t as matrixPlugin } from "./channel-DBu5bvBi.js";
2
2
  export { matrixPlugin };
@@ -1,7 +1,7 @@
1
1
  import { a as resolveMatrixAccountConfig, i as resolveMatrixAccountAllowlistConfig } from "./account-config-BZWN9tGS.js";
2
2
  import { t as getMatrixRuntime } from "./runtime-6S3DNFNv.js";
3
3
  import { m as resolveConfiguredMatrixBotUserIds } from "./setup-core-Ub_idsu1.js";
4
- import { a as buildAllowlistResolutionSummary, c as createTypingCallbacks, d as logInboundDrop, f as logTypingFailure, h as toLocationContext, i as addAllowlistUserEntriesFromConfigEntry, l as formatLocationText, m as summarizeMapping, n as resolveMatrixStoredSessionMeta, o as canonicalizeAllowlistWithResolvedIds, p as patchAllowlistUsersInConfigEntries, r as resolveMatrixRoomConfig, s as createReplyPrefixOptions, u as getAgentScopedMediaLocalRoots } from "./channel-Y_HGdzpZ.js";
4
+ import { a as buildAllowlistResolutionSummary, c as createTypingCallbacks, d as logInboundDrop, f as logTypingFailure, h as toLocationContext, i as addAllowlistUserEntriesFromConfigEntry, l as formatLocationText, m as summarizeMapping, n as resolveMatrixStoredSessionMeta, o as canonicalizeAllowlistWithResolvedIds, p as patchAllowlistUsersInConfigEntries, r as resolveMatrixRoomConfig, s as createReplyPrefixOptions, u as getAgentScopedMediaLocalRoots } from "./channel-DBu5bvBi.js";
5
5
  import { a as normalizeMatrixUserId, i as normalizeMatrixAllowList, o as resolveMatrixAllowListMatch } from "./config-schema-o1UmRtMF.js";
6
6
  import { t as isMatrixQualifiedUserId } from "./target-ids-B-5aQxwn.js";
7
7
  import { r as isMatrixNotFoundError, t as formatMatrixErrorMessage } from "./errors-C47hvAF8.js";
@@ -3882,12 +3882,15 @@ function pruneSeenEvents(params) {
3882
3882
  seen.delete(oldestKey);
3883
3883
  }
3884
3884
  }
3885
- function createInboundDedupeStore(params) {
3886
- return getMatrixRuntime().state.openKeyedStore({
3885
+ function openMatrixInboundDedupeStoreOptions(params) {
3886
+ return {
3887
3887
  namespace: INBOUND_DEDUPE_NAMESPACE,
3888
3888
  maxEntries: DEFAULT_MAX_ENTRIES,
3889
3889
  env: resolveMatrixSqliteStateEnv(params)
3890
- });
3890
+ };
3891
+ }
3892
+ function createInboundDedupeStore(params) {
3893
+ return getMatrixRuntime().state.openKeyedStore(openMatrixInboundDedupeStoreOptions(params));
3891
3894
  }
3892
3895
  function createInboundDedupeMigrationStore(params) {
3893
3896
  return getMatrixRuntime().state.openKeyedStore({
@@ -3,8 +3,7 @@ linkify-it
3
3
 
4
4
  [![CI](https://github.com/markdown-it/linkify-it/actions/workflows/ci.yml/badge.svg)](https://github.com/markdown-it/linkify-it/actions/workflows/ci.yml)
5
5
  [![NPM version](https://img.shields.io/npm/v/linkify-it.svg?style=flat)](https://www.npmjs.org/package/linkify-it)
6
- [![Coverage Status](https://img.shields.io/coveralls/markdown-it/linkify-it/master.svg?style=flat)](https://coveralls.io/r/markdown-it/linkify-it?branch=master)
7
- [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/markdown-it/linkify-it)
6
+ [![Coverage Status](https://coveralls.io/repos/github/markdown-it/linkify-it/badge.svg?branch=master)](https://coveralls.io/github/markdown-it/linkify-it?branch=master)
8
7
 
9
8
  > Links recognition library with FULL unicode support.
10
9
  > Focused on high quality link patterns detection in plain text.
@@ -66,7 +65,7 @@ linkify.add('@', {
66
65
 
67
66
  if (!self.re.twitter) {
68
67
  self.re.twitter = new RegExp(
69
- '^([a-zA-Z0-9_]){1,15}(?!_)(?=$|' + self.re.src_ZPCc + ')'
68
+ `^([a-zA-Z0-9_]){1,15}(?!_)(?=$|${self.re.src_ZPCc})`
70
69
  );
71
70
  }
72
71
  if (self.re.twitter.test(tail)) {
@@ -80,7 +79,7 @@ linkify.add('@', {
80
79
  return 0;
81
80
  },
82
81
  normalize: function (match) {
83
- match.url = 'https://twitter.com/' + match.url.replace(/^@/, '');
82
+ match.url = `https://twitter.com/${match.url.replace(/^@/, '')}`;
84
83
  }
85
84
  });
86
85
  ```
@@ -24,7 +24,7 @@ function reFactory (opts) {
24
24
  // All possible word characters (everything without punctuation, spaces & controls)
25
25
  // Defined via punctuation & spaces to save space
26
26
  // Should be something like \p{\L\N\S\M} (\w but without `_`)
27
- re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')';
27
+ re.src_pseudo_letter = `(?:(?!${text_separators}|${re.src_ZPCc})${re.src_Any})`;
28
28
  // The same as abothe but without [0-9]
29
29
  // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
30
30
 
@@ -33,7 +33,9 @@ function reFactory (opts) {
33
33
  '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
34
34
 
35
35
  // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
36
- re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?';
36
+ // Length is capped to exclude possible rescans till the end and avoid O(n^2)
37
+ // DoS. No standard limit, just take something reasonable.
38
+ re.src_auth = `(?:(?:(?!${re.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`;
37
39
 
38
40
  re.src_port =
39
41
 
@@ -41,23 +43,23 @@ function reFactory (opts) {
41
43
 
42
44
  re.src_host_terminator =
43
45
 
44
- '(?=$|' + text_separators + '|' + re.src_ZPCc + ')' +
45
- '(?!' + (opts['---'] ? '-(?!--)|' : '-|') + '_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))';
46
+ `(?=$|${text_separators}|${re.src_ZPCc})` +
47
+ `(?!${opts['---'] ? '-(?!--)|' : '-|'}_|:\\d|\\.-|\\.(?!$|${re.src_ZPCc}))`;
46
48
 
47
49
  re.src_path =
48
50
 
49
51
  '(?:' +
50
52
  '[/?#]' +
51
53
  '(?:' +
52
- '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-;]).|' +
53
- '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
54
- '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
55
- '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
56
- '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
57
- "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
54
+ `(?!${re.src_ZCc}|${text_separators}|[()[\\]{}.,"'?!\\-;]).|` +
55
+ `\\[(?:(?!${re.src_ZCc}|\\]).)*\\]|` +
56
+ `\\((?:(?!${re.src_ZCc}|[)]).)*\\)|` +
57
+ `\\{(?:(?!${re.src_ZCc}|[}]).)*\\}|` +
58
+ `\\"(?:(?!${re.src_ZCc}|["]).)+\\"|` +
59
+ `\\'(?:(?!${re.src_ZCc}|[']).)+\\'|` +
58
60
 
59
61
  // allow `I'm_king` if no pair found
60
- "\\'(?=" + re.src_pseudo_letter + '|[-])|' +
62
+ `\\'(?=${re.src_pseudo_letter}|[-])|` +
61
63
 
62
64
  // google has many dots in "google search" links (#66, #81).
63
65
  // github has ... in commit range links,
@@ -69,30 +71,32 @@ function reFactory (opts) {
69
71
  // until more examples found.
70
72
  '\\.{2,}[a-zA-Z0-9%/&]|' +
71
73
 
72
- '\\.(?!' + re.src_ZCc + '|[.]|$)|' +
74
+ `\\.(?!${re.src_ZCc}|[.]|$)|` +
73
75
  (opts['---']
74
76
  ? '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
75
77
  : '\\-+|'
76
78
  ) +
77
79
  // allow `,,,` in paths
78
- ',(?!' + re.src_ZCc + '|$)|' +
80
+ `,(?!${re.src_ZCc}|$)|` +
79
81
 
80
82
  // allow `;` if not followed by space-like char
81
- ';(?!' + re.src_ZCc + '|$)|' +
83
+ `;(?!${re.src_ZCc}|$)|` +
82
84
 
83
85
  // allow `!!!` in paths, but not at the end
84
- '\\!+(?!' + re.src_ZCc + '|[!]|$)|' +
86
+ `\\!+(?!${re.src_ZCc}|[!]|$)|` +
85
87
 
86
- '\\?(?!' + re.src_ZCc + '|[?]|$)' +
88
+ `\\?(?!${re.src_ZCc}|[?]|$)` +
87
89
  ')+' +
88
90
  '|\\/' +
89
91
  ')?';
90
92
 
91
93
  // Allow anything in markdown spec, forbid quote (") at the first position
92
94
  // because emails enclosed in quotes are far more common
95
+ // Max name length capped to 64 chars (RFC 5321). This also prevents O(n^2)
96
+ // rescans to the end on inputs like `mailto:mailto:...`
93
97
  re.src_email_name =
94
98
 
95
- '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*';
99
+ '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}';
96
100
 
97
101
  re.src_xn =
98
102
 
@@ -107,7 +111,7 @@ function reFactory (opts) {
107
111
  '(?:' +
108
112
  re.src_xn +
109
113
  '|' +
110
- re.src_pseudo_letter + '{1,63}' +
114
+ `${re.src_pseudo_letter}{1,63}` +
111
115
  ')';
112
116
 
113
117
  re.src_domain =
@@ -115,9 +119,9 @@ function reFactory (opts) {
115
119
  '(?:' +
116
120
  re.src_xn +
117
121
  '|' +
118
- '(?:' + re.src_pseudo_letter + ')' +
122
+ `(?:${re.src_pseudo_letter})` +
119
123
  '|' +
120
- '(?:' + re.src_pseudo_letter + '(?:-|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
124
+ `(?:${re.src_pseudo_letter}(?:-|${re.src_pseudo_letter}){0,61}${re.src_pseudo_letter})` +
121
125
  ')';
122
126
 
123
127
  re.src_host =
@@ -126,7 +130,7 @@ function reFactory (opts) {
126
130
  // Don't need IP check, because digits are already allowed in normal domain names
127
131
  // src_ip4 +
128
132
  // '|' +
129
- '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/* _root */ + ')' +
133
+ `(?:(?:(?:${re.src_domain})\\.)*${re.src_domain})`/* _root */ +
130
134
  ')';
131
135
 
132
136
  re.tpl_host_fuzzy =
@@ -134,12 +138,12 @@ function reFactory (opts) {
134
138
  '(?:' +
135
139
  re.src_ip4 +
136
140
  '|' +
137
- '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
141
+ `(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))` +
138
142
  ')';
139
143
 
140
144
  re.tpl_host_no_ip_fuzzy =
141
145
 
142
- '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))';
146
+ `(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))`;
143
147
 
144
148
  re.src_host_strict =
145
149
 
@@ -168,24 +172,24 @@ function reFactory (opts) {
168
172
  // Rude test fuzzy links by host, for quick deny
169
173
  re.tpl_host_fuzzy_test =
170
174
 
171
- 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))';
175
+ `localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${re.src_ZPCc}|>|$))`;
172
176
 
173
177
  re.tpl_email_fuzzy =
174
178
 
175
- '(^|' + text_separators + '|"|\\(|' + re.src_ZCc + ')' +
176
- '(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')';
179
+ `(^|${text_separators}|"|\\(|${re.src_ZCc})` +
180
+ `(${re.src_email_name}@${re.tpl_host_fuzzy_strict})`;
177
181
 
178
182
  re.tpl_link_fuzzy =
179
183
  // Fuzzy link can't be prepended with .:/\- and non punctuation.
180
184
  // but can start with > (markdown blockquote)
181
- '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
182
- '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')';
185
+ `(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
186
+ `((?![$+<=>^\`|\uff5c])${re.tpl_host_port_fuzzy_strict}${re.src_path})`;
183
187
 
184
188
  re.tpl_link_no_ip_fuzzy =
185
189
  // Fuzzy link can't be prepended with .:/\- and non punctuation.
186
190
  // but can start with > (markdown blockquote)
187
- '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
188
- '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')';
191
+ `(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
192
+ `((?![$+<=>^\`|\uff5c])${re.tpl_host_port_no_ip_fuzzy_strict}${re.src_path})`;
189
193
 
190
194
  return re
191
195
  }
@@ -241,7 +245,7 @@ const defaultSchemas = {
241
245
  if (!self.re.http) {
242
246
  // compile lazily, because "host"-containing variables can change on tlds update.
243
247
  self.re.http = new RegExp(
244
- '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
248
+ `^\\/\\/${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`, 'i'
245
249
  );
246
250
  }
247
251
  if (self.re.http.test(tail)) {
@@ -263,7 +267,7 @@ const defaultSchemas = {
263
267
  self.re.src_auth +
264
268
  // Don't allow single-level domains, because of false positives like '//test'
265
269
  // with code comments
266
- '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
270
+ `(?:localhost|(?:(?:${self.re.src_domain})\\.)+${self.re.src_domain_root})` +
267
271
  self.re.src_port +
268
272
  self.re.src_host_terminator +
269
273
  self.re.src_path,
@@ -287,7 +291,7 @@ const defaultSchemas = {
287
291
 
288
292
  if (!self.re.mailto) {
289
293
  self.re.mailto = new RegExp(
290
- '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
294
+ `^${self.re.src_email_name}@${self.re.src_host_strict}`, 'i'
291
295
  );
292
296
  }
293
297
  if (self.re.mailto.test(tail)) {
@@ -299,7 +303,6 @@ const defaultSchemas = {
299
303
  };
300
304
 
301
305
  // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
302
- /* eslint-disable-next-line max-len */
303
306
  const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]';
304
307
 
305
308
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
@@ -359,7 +362,7 @@ function compile (self) {
359
362
  self.__compiled__ = {}; // Reset compiled data
360
363
 
361
364
  function schemaError (name, val) {
362
- throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val)
365
+ throw new Error(`(LinkifyIt) Invalid schema "${name}": ${val}`)
363
366
  }
364
367
 
365
368
  Object.keys(self.__schemas__).forEach(function (name) {
@@ -433,12 +436,12 @@ function compile (self) {
433
436
  .map(escapeRE)
434
437
  .join('|');
435
438
  // (?!_) cause 1.5x slowdown
436
- self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i');
437
- self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig');
438
- self.re.schema_at_start = RegExp('^' + self.re.schema_search.source, 'i');
439
+ self.re.schema_test = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'i');
440
+ self.re.schema_search = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'ig');
441
+ self.re.schema_at_start = RegExp(`^${self.re.schema_search.source}`, 'i');
439
442
 
440
443
  self.re.pretest = RegExp(
441
- '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
444
+ `(${self.re.schema_test.source})|(${self.re.host_fuzzy_test.source})|@`,
442
445
  'i'
443
446
  );
444
447
  }
@@ -819,10 +822,10 @@ LinkifyIt.prototype.normalize = function normalize (match) {
819
822
  // Do minimal possible changes by default. Need to collect feedback prior
820
823
  // to move forward https://github.com/markdown-it/linkify-it/issues/1
821
824
 
822
- if (!match.schema) { match.url = 'http://' + match.url; }
825
+ if (!match.schema) { match.url = `http://${match.url}`; }
823
826
 
824
827
  if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
825
- match.url = 'mailto:' + match.url;
828
+ match.url = `mailto:${match.url}`;
826
829
  }
827
830
  };
828
831
 
@@ -51,7 +51,7 @@ const defaultSchemas = {
51
51
  if (!self.re.http) {
52
52
  // compile lazily, because "host"-containing variables can change on tlds update.
53
53
  self.re.http = new RegExp(
54
- '^\\/\\/' + self.re.src_auth + self.re.src_host_port_strict + self.re.src_path, 'i'
54
+ `^\\/\\/${self.re.src_auth}${self.re.src_host_port_strict}${self.re.src_path}`, 'i'
55
55
  )
56
56
  }
57
57
  if (self.re.http.test(tail)) {
@@ -73,7 +73,7 @@ const defaultSchemas = {
73
73
  self.re.src_auth +
74
74
  // Don't allow single-level domains, because of false positives like '//test'
75
75
  // with code comments
76
- '(?:localhost|(?:(?:' + self.re.src_domain + ')\\.)+' + self.re.src_domain_root + ')' +
76
+ `(?:localhost|(?:(?:${self.re.src_domain})\\.)+${self.re.src_domain_root})` +
77
77
  self.re.src_port +
78
78
  self.re.src_host_terminator +
79
79
  self.re.src_path,
@@ -97,7 +97,7 @@ const defaultSchemas = {
97
97
 
98
98
  if (!self.re.mailto) {
99
99
  self.re.mailto = new RegExp(
100
- '^' + self.re.src_email_name + '@' + self.re.src_host_strict, 'i'
100
+ `^${self.re.src_email_name}@${self.re.src_host_strict}`, 'i'
101
101
  )
102
102
  }
103
103
  if (self.re.mailto.test(tail)) {
@@ -109,7 +109,6 @@ const defaultSchemas = {
109
109
  }
110
110
 
111
111
  // RE pattern for 2-character tlds (autogenerated by ./support/tlds_2char_gen.js)
112
- /* eslint-disable-next-line max-len */
113
112
  const tlds_2ch_src_re = 'a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]'
114
113
 
115
114
  // DON'T try to make PRs with changes. Extend TLDs with LinkifyIt.tlds() instead
@@ -169,7 +168,7 @@ function compile (self) {
169
168
  self.__compiled__ = {} // Reset compiled data
170
169
 
171
170
  function schemaError (name, val) {
172
- throw new Error('(LinkifyIt) Invalid schema "' + name + '": ' + val)
171
+ throw new Error(`(LinkifyIt) Invalid schema "${name}": ${val}`)
173
172
  }
174
173
 
175
174
  Object.keys(self.__schemas__).forEach(function (name) {
@@ -243,12 +242,12 @@ function compile (self) {
243
242
  .map(escapeRE)
244
243
  .join('|')
245
244
  // (?!_) cause 1.5x slowdown
246
- self.re.schema_test = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'i')
247
- self.re.schema_search = RegExp('(^|(?!_)(?:[><\uff5c]|' + re.src_ZPCc + '))(' + slist + ')', 'ig')
248
- self.re.schema_at_start = RegExp('^' + self.re.schema_search.source, 'i')
245
+ self.re.schema_test = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'i')
246
+ self.re.schema_search = RegExp(`(^|(?!_)(?:[><\uff5c]|${re.src_ZPCc}))(${slist})`, 'ig')
247
+ self.re.schema_at_start = RegExp(`^${self.re.schema_search.source}`, 'i')
249
248
 
250
249
  self.re.pretest = RegExp(
251
- '(' + self.re.schema_test.source + ')|(' + self.re.host_fuzzy_test.source + ')|@',
250
+ `(${self.re.schema_test.source})|(${self.re.host_fuzzy_test.source})|@`,
252
251
  'i'
253
252
  )
254
253
  }
@@ -629,10 +628,10 @@ LinkifyIt.prototype.normalize = function normalize (match) {
629
628
  // Do minimal possible changes by default. Need to collect feedback prior
630
629
  // to move forward https://github.com/markdown-it/linkify-it/issues/1
631
630
 
632
- if (!match.schema) { match.url = 'http://' + match.url }
631
+ if (!match.schema) { match.url = `http://${match.url}` }
633
632
 
634
633
  if (match.schema === 'mailto:' && !/^mailto:/i.test(match.url)) {
635
- match.url = 'mailto:' + match.url
634
+ match.url = `mailto:${match.url}`
636
635
  }
637
636
  }
638
637
 
@@ -22,7 +22,7 @@ export default function (opts) {
22
22
  // All possible word characters (everything without punctuation, spaces & controls)
23
23
  // Defined via punctuation & spaces to save space
24
24
  // Should be something like \p{\L\N\S\M} (\w but without `_`)
25
- re.src_pseudo_letter = '(?:(?!' + text_separators + '|' + re.src_ZPCc + ')' + re.src_Any + ')'
25
+ re.src_pseudo_letter = `(?:(?!${text_separators}|${re.src_ZPCc})${re.src_Any})`
26
26
  // The same as abothe but without [0-9]
27
27
  // var src_pseudo_letter_non_d = '(?:(?![0-9]|' + src_ZPCc + ')' + src_Any + ')';
28
28
 
@@ -31,7 +31,9 @@ export default function (opts) {
31
31
  '(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)'
32
32
 
33
33
  // Prohibit any of "@/[]()" in user/pass to avoid wrong domain fetch.
34
- re.src_auth = '(?:(?:(?!' + re.src_ZCc + '|[@/\\[\\]()]).)+@)?'
34
+ // Length is capped to exclude possible rescans till the end and avoid O(n^2)
35
+ // DoS. No standard limit, just take something reasonable.
36
+ re.src_auth = `(?:(?:(?!${re.src_ZCc}|[@/\\[\\]()]).){1,50}@)?`
35
37
 
36
38
  re.src_port =
37
39
 
@@ -39,23 +41,23 @@ export default function (opts) {
39
41
 
40
42
  re.src_host_terminator =
41
43
 
42
- '(?=$|' + text_separators + '|' + re.src_ZPCc + ')' +
43
- '(?!' + (opts['---'] ? '-(?!--)|' : '-|') + '_|:\\d|\\.-|\\.(?!$|' + re.src_ZPCc + '))'
44
+ `(?=$|${text_separators}|${re.src_ZPCc})` +
45
+ `(?!${opts['---'] ? '-(?!--)|' : '-|'}_|:\\d|\\.-|\\.(?!$|${re.src_ZPCc}))`
44
46
 
45
47
  re.src_path =
46
48
 
47
49
  '(?:' +
48
50
  '[/?#]' +
49
51
  '(?:' +
50
- '(?!' + re.src_ZCc + '|' + text_separators + '|[()[\\]{}.,"\'?!\\-;]).|' +
51
- '\\[(?:(?!' + re.src_ZCc + '|\\]).)*\\]|' +
52
- '\\((?:(?!' + re.src_ZCc + '|[)]).)*\\)|' +
53
- '\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +
54
- '\\"(?:(?!' + re.src_ZCc + '|["]).)+\\"|' +
55
- "\\'(?:(?!" + re.src_ZCc + "|[']).)+\\'|" +
52
+ `(?!${re.src_ZCc}|${text_separators}|[()[\\]{}.,"'?!\\-;]).|` +
53
+ `\\[(?:(?!${re.src_ZCc}|\\]).)*\\]|` +
54
+ `\\((?:(?!${re.src_ZCc}|[)]).)*\\)|` +
55
+ `\\{(?:(?!${re.src_ZCc}|[}]).)*\\}|` +
56
+ `\\"(?:(?!${re.src_ZCc}|["]).)+\\"|` +
57
+ `\\'(?:(?!${re.src_ZCc}|[']).)+\\'|` +
56
58
 
57
59
  // allow `I'm_king` if no pair found
58
- "\\'(?=" + re.src_pseudo_letter + '|[-])|' +
60
+ `\\'(?=${re.src_pseudo_letter}|[-])|` +
59
61
 
60
62
  // google has many dots in "google search" links (#66, #81).
61
63
  // github has ... in commit range links,
@@ -67,30 +69,32 @@ export default function (opts) {
67
69
  // until more examples found.
68
70
  '\\.{2,}[a-zA-Z0-9%/&]|' +
69
71
 
70
- '\\.(?!' + re.src_ZCc + '|[.]|$)|' +
72
+ `\\.(?!${re.src_ZCc}|[.]|$)|` +
71
73
  (opts['---']
72
74
  ? '\\-(?!--(?:[^-]|$))(?:-*)|' // `---` => long dash, terminate
73
75
  : '\\-+|'
74
76
  ) +
75
77
  // allow `,,,` in paths
76
- ',(?!' + re.src_ZCc + '|$)|' +
78
+ `,(?!${re.src_ZCc}|$)|` +
77
79
 
78
80
  // allow `;` if not followed by space-like char
79
- ';(?!' + re.src_ZCc + '|$)|' +
81
+ `;(?!${re.src_ZCc}|$)|` +
80
82
 
81
83
  // allow `!!!` in paths, but not at the end
82
- '\\!+(?!' + re.src_ZCc + '|[!]|$)|' +
84
+ `\\!+(?!${re.src_ZCc}|[!]|$)|` +
83
85
 
84
- '\\?(?!' + re.src_ZCc + '|[?]|$)' +
86
+ `\\?(?!${re.src_ZCc}|[?]|$)` +
85
87
  ')+' +
86
88
  '|\\/' +
87
89
  ')?'
88
90
 
89
91
  // Allow anything in markdown spec, forbid quote (") at the first position
90
92
  // because emails enclosed in quotes are far more common
93
+ // Max name length capped to 64 chars (RFC 5321). This also prevents O(n^2)
94
+ // rescans to the end on inputs like `mailto:mailto:...`
91
95
  re.src_email_name =
92
96
 
93
- '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*'
97
+ '[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]{0,63}'
94
98
 
95
99
  re.src_xn =
96
100
 
@@ -105,7 +109,7 @@ export default function (opts) {
105
109
  '(?:' +
106
110
  re.src_xn +
107
111
  '|' +
108
- re.src_pseudo_letter + '{1,63}' +
112
+ `${re.src_pseudo_letter}{1,63}` +
109
113
  ')'
110
114
 
111
115
  re.src_domain =
@@ -113,9 +117,9 @@ export default function (opts) {
113
117
  '(?:' +
114
118
  re.src_xn +
115
119
  '|' +
116
- '(?:' + re.src_pseudo_letter + ')' +
120
+ `(?:${re.src_pseudo_letter})` +
117
121
  '|' +
118
- '(?:' + re.src_pseudo_letter + '(?:-|' + re.src_pseudo_letter + '){0,61}' + re.src_pseudo_letter + ')' +
122
+ `(?:${re.src_pseudo_letter}(?:-|${re.src_pseudo_letter}){0,61}${re.src_pseudo_letter})` +
119
123
  ')'
120
124
 
121
125
  re.src_host =
@@ -124,7 +128,7 @@ export default function (opts) {
124
128
  // Don't need IP check, because digits are already allowed in normal domain names
125
129
  // src_ip4 +
126
130
  // '|' +
127
- '(?:(?:(?:' + re.src_domain + ')\\.)*' + re.src_domain/* _root */ + ')' +
131
+ `(?:(?:(?:${re.src_domain})\\.)*${re.src_domain})`/* _root */ +
128
132
  ')'
129
133
 
130
134
  re.tpl_host_fuzzy =
@@ -132,12 +136,12 @@ export default function (opts) {
132
136
  '(?:' +
133
137
  re.src_ip4 +
134
138
  '|' +
135
- '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))' +
139
+ `(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))` +
136
140
  ')'
137
141
 
138
142
  re.tpl_host_no_ip_fuzzy =
139
143
 
140
- '(?:(?:(?:' + re.src_domain + ')\\.)+(?:%TLDS%))'
144
+ `(?:(?:(?:${re.src_domain})\\.)+(?:%TLDS%))`
141
145
 
142
146
  re.src_host_strict =
143
147
 
@@ -166,24 +170,24 @@ export default function (opts) {
166
170
  // Rude test fuzzy links by host, for quick deny
167
171
  re.tpl_host_fuzzy_test =
168
172
 
169
- 'localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:' + re.src_ZPCc + '|>|$))'
173
+ `localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:${re.src_ZPCc}|>|$))`
170
174
 
171
175
  re.tpl_email_fuzzy =
172
176
 
173
- '(^|' + text_separators + '|"|\\(|' + re.src_ZCc + ')' +
174
- '(' + re.src_email_name + '@' + re.tpl_host_fuzzy_strict + ')'
177
+ `(^|${text_separators}|"|\\(|${re.src_ZCc})` +
178
+ `(${re.src_email_name}@${re.tpl_host_fuzzy_strict})`
175
179
 
176
180
  re.tpl_link_fuzzy =
177
181
  // Fuzzy link can't be prepended with .:/\- and non punctuation.
178
182
  // but can start with > (markdown blockquote)
179
- '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
180
- '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_fuzzy_strict + re.src_path + ')'
183
+ `(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
184
+ `((?![$+<=>^\`|\uff5c])${re.tpl_host_port_fuzzy_strict}${re.src_path})`
181
185
 
182
186
  re.tpl_link_no_ip_fuzzy =
183
187
  // Fuzzy link can't be prepended with .:/\- and non punctuation.
184
188
  // but can start with > (markdown blockquote)
185
- '(^|(?![.:/\\-_@])(?:[$+<=>^`|\uff5c]|' + re.src_ZPCc + '))' +
186
- '((?![$+<=>^`|\uff5c])' + re.tpl_host_port_no_ip_fuzzy_strict + re.src_path + ')'
189
+ `(^|(?![.:/\\-_@])(?:[$+<=>^\`|\uff5c]|${re.src_ZPCc}))` +
190
+ `((?![$+<=>^\`|\uff5c])${re.tpl_host_port_no_ip_fuzzy_strict}${re.src_path})`
187
191
 
188
192
  return re
189
193
  }