@zowe/cli 8.37.1 → 8.39.0

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 (186) hide show
  1. package/lib/zosfiles/edit/Edit.utils.d.ts.map +1 -1
  2. package/lib/zosfiles/edit/Edit.utils.js.map +1 -1
  3. package/node_modules/@zowe/core-for-zowe-sdk/lib/constants/Core.constants.d.ts +8 -0
  4. package/node_modules/@zowe/core-for-zowe-sdk/lib/constants/Core.constants.d.ts.map +1 -1
  5. package/node_modules/@zowe/core-for-zowe-sdk/lib/constants/Core.constants.js +31 -0
  6. package/node_modules/@zowe/core-for-zowe-sdk/lib/constants/Core.constants.js.map +1 -1
  7. package/node_modules/@zowe/core-for-zowe-sdk/package.json +3 -3
  8. package/node_modules/@zowe/imperative/lib/config/src/ProfileCredentials.d.ts.map +1 -1
  9. package/node_modules/@zowe/imperative/lib/config/src/ProfileCredentials.js +15 -1
  10. package/node_modules/@zowe/imperative/lib/config/src/ProfileCredentials.js.map +1 -1
  11. package/node_modules/@zowe/imperative/lib/imperative/src/config/cmd/report-env/EnvQuery.d.ts.map +1 -1
  12. package/node_modules/@zowe/imperative/lib/imperative/src/config/cmd/report-env/EnvQuery.js +1 -2
  13. package/node_modules/@zowe/imperative/lib/imperative/src/config/cmd/report-env/EnvQuery.js.map +1 -1
  14. package/node_modules/@zowe/imperative/lib/rest/index.d.ts +1 -0
  15. package/node_modules/@zowe/imperative/lib/rest/index.d.ts.map +1 -1
  16. package/node_modules/@zowe/imperative/lib/rest/index.js +1 -0
  17. package/node_modules/@zowe/imperative/lib/rest/index.js.map +1 -1
  18. package/node_modules/@zowe/imperative/lib/rest/src/session/AbstractSession.d.ts +16 -2
  19. package/node_modules/@zowe/imperative/lib/rest/src/session/AbstractSession.d.ts.map +1 -1
  20. package/node_modules/@zowe/imperative/lib/rest/src/session/AbstractSession.js +57 -9
  21. package/node_modules/@zowe/imperative/lib/rest/src/session/AbstractSession.js.map +1 -1
  22. package/node_modules/@zowe/imperative/lib/rest/src/session/SessConstants.d.ts +29 -0
  23. package/node_modules/@zowe/imperative/lib/rest/src/session/SessConstants.d.ts.map +1 -1
  24. package/node_modules/@zowe/imperative/lib/rest/src/session/SessConstants.js +32 -1
  25. package/node_modules/@zowe/imperative/lib/rest/src/session/SessConstants.js.map +1 -1
  26. package/node_modules/@zowe/imperative/lib/rest/src/session/doc/IApimlDecision.d.ts +44 -0
  27. package/node_modules/@zowe/imperative/lib/rest/src/session/doc/IApimlDecision.d.ts.map +1 -0
  28. package/node_modules/@zowe/imperative/lib/rest/src/session/doc/IApimlDecision.js +40 -0
  29. package/node_modules/@zowe/imperative/lib/rest/src/session/doc/IApimlDecision.js.map +1 -0
  30. package/node_modules/@zowe/imperative/lib/rest/src/session/doc/ISession.d.ts +11 -0
  31. package/node_modules/@zowe/imperative/lib/rest/src/session/doc/ISession.d.ts.map +1 -1
  32. package/node_modules/@zowe/imperative/package.json +2 -2
  33. package/node_modules/@zowe/imperative/web-help/package-lock.json +62 -61
  34. package/node_modules/@zowe/provisioning-for-zowe-sdk/package.json +4 -4
  35. package/node_modules/@zowe/secrets-for-zowe-sdk/package.json +1 -1
  36. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.darwin-arm64.node +0 -0
  37. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.darwin-x64.node +0 -0
  38. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-arm-gnueabihf.node +0 -0
  39. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-arm64-gnu.node +0 -0
  40. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-arm64-musl.node +0 -0
  41. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-ia32-gnu.node +0 -0
  42. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-x64-gnu.node +0 -0
  43. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.linux-x64-musl.node +0 -0
  44. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.win32-arm64-msvc.node +0 -0
  45. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.win32-ia32-msvc.node +0 -0
  46. package/node_modules/@zowe/secrets-for-zowe-sdk/prebuilds/keyring.win32-x64-msvc.node +0 -0
  47. package/node_modules/@zowe/secrets-for-zowe-sdk/src/keyring/index.js +86 -18
  48. package/node_modules/@zowe/zos-console-for-zowe-sdk/package.json +4 -4
  49. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/constants/ZosFiles.messages.d.ts.map +1 -1
  50. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/constants/ZosFiles.messages.js +27 -0
  51. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/constants/ZosFiles.messages.js.map +1 -1
  52. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/create/Create.d.ts.map +1 -1
  53. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/create/Create.js +57 -2
  54. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/create/Create.js.map +1 -1
  55. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/delete/Delete.d.ts.map +1 -1
  56. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/delete/Delete.js +1 -0
  57. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/delete/Delete.js.map +1 -1
  58. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/list/List.d.ts.map +1 -1
  59. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/list/List.js +1 -0
  60. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/list/List.js.map +1 -1
  61. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.d.ts +10 -0
  62. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.d.ts.map +1 -1
  63. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.js +43 -17
  64. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/methods/utilities/Utilities.js.map +1 -1
  65. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.d.ts +25 -0
  66. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.d.ts.map +1 -1
  67. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.js +53 -0
  68. package/node_modules/@zowe/zos-files-for-zowe-sdk/lib/utils/ZosFilesUtils.js.map +1 -1
  69. package/node_modules/@zowe/zos-files-for-zowe-sdk/package.json +5 -5
  70. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/CancelJobs.d.ts.map +1 -1
  71. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/CancelJobs.js +2 -0
  72. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/CancelJobs.js.map +1 -1
  73. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/DeleteJobs.d.ts.map +1 -1
  74. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/DeleteJobs.js +2 -0
  75. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/DeleteJobs.js.map +1 -1
  76. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/DownloadJobs.d.ts.map +1 -1
  77. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/DownloadJobs.js +3 -0
  78. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/DownloadJobs.js.map +1 -1
  79. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/GetJobs.d.ts.map +1 -1
  80. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/GetJobs.js +8 -0
  81. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/GetJobs.js.map +1 -1
  82. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsMessages.d.ts.map +1 -1
  83. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsMessages.js +24 -0
  84. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsMessages.js.map +1 -1
  85. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsUtils.d.ts +39 -0
  86. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsUtils.d.ts.map +1 -0
  87. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsUtils.js +72 -0
  88. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/JobsUtils.js.map +1 -0
  89. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/ModifyJobs.d.ts.map +1 -1
  90. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/ModifyJobs.js +2 -0
  91. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/ModifyJobs.js.map +1 -1
  92. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/SearchJobs.d.ts.map +1 -1
  93. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/SearchJobs.js +3 -0
  94. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/lib/SearchJobs.js.map +1 -1
  95. package/node_modules/@zowe/zos-jobs-for-zowe-sdk/package.json +5 -5
  96. package/node_modules/@zowe/zos-logs-for-zowe-sdk/package.json +4 -4
  97. package/node_modules/@zowe/zos-tso-for-zowe-sdk/package.json +5 -5
  98. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/Shell.d.ts.map +1 -1
  99. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/Shell.js +1 -1
  100. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/Shell.js.map +1 -1
  101. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/SshSession.d.ts.map +1 -1
  102. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/SshSession.js.map +1 -1
  103. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/doc/ISshSession.d.ts +14 -0
  104. package/node_modules/@zowe/zos-uss-for-zowe-sdk/lib/doc/ISshSession.d.ts.map +1 -1
  105. package/node_modules/@zowe/zos-uss-for-zowe-sdk/package.json +3 -3
  106. package/node_modules/@zowe/zos-workflows-for-zowe-sdk/lib/Create.d.ts.map +1 -1
  107. package/node_modules/@zowe/zos-workflows-for-zowe-sdk/lib/Create.js +3 -2
  108. package/node_modules/@zowe/zos-workflows-for-zowe-sdk/lib/Create.js.map +1 -1
  109. package/node_modules/@zowe/zos-workflows-for-zowe-sdk/package.json +5 -5
  110. package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.profile.d.ts.map +1 -1
  111. package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.profile.js +9 -0
  112. package/node_modules/@zowe/zosmf-for-zowe-sdk/lib/constants/Zosmf.profile.js.map +1 -1
  113. package/node_modules/@zowe/zosmf-for-zowe-sdk/package.json +4 -4
  114. package/node_modules/brace-expansion/dist/commonjs/index.d.ts +4 -0
  115. package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -1
  116. package/node_modules/brace-expansion/dist/commonjs/index.js +69 -25
  117. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -1
  118. package/node_modules/brace-expansion/dist/esm/index.d.ts +4 -0
  119. package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -1
  120. package/node_modules/brace-expansion/dist/esm/index.js +68 -24
  121. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -1
  122. package/node_modules/brace-expansion/package.json +2 -1
  123. package/node_modules/cpu-features/.github/workflows/ci.yml +15 -9
  124. package/node_modules/cpu-features/.github/workflows/lint.yml +2 -2
  125. package/node_modules/cpu-features/deps/cpu_features/cpu_features.gyp +1 -0
  126. package/node_modules/cpu-features/package.json +2 -2
  127. package/node_modules/markdown-it/dist/index.cjs.js +3696 -5376
  128. package/node_modules/markdown-it/dist/index.cjs.js.map +1 -0
  129. package/node_modules/markdown-it/dist/markdown-it.js +1446 -4481
  130. package/node_modules/markdown-it/dist/markdown-it.js.map +1 -0
  131. package/node_modules/markdown-it/dist/markdown-it.min.js +3 -2
  132. package/node_modules/markdown-it/dist/markdown-it.min.js.map +1 -0
  133. package/node_modules/markdown-it/lib/common/html_re.mjs +9 -9
  134. package/node_modules/markdown-it/lib/common/utils.mjs +2 -11
  135. package/node_modules/markdown-it/lib/helpers/parse_link_destination.mjs +1 -1
  136. package/node_modules/markdown-it/lib/parser_block.mjs +9 -9
  137. package/node_modules/markdown-it/lib/parser_core.mjs +7 -7
  138. package/node_modules/markdown-it/lib/parser_inline.mjs +16 -16
  139. package/node_modules/markdown-it/lib/renderer.mjs +2 -2
  140. package/node_modules/markdown-it/lib/rules_block/blockquote.mjs +6 -6
  141. package/node_modules/markdown-it/lib/rules_block/code.mjs +2 -2
  142. package/node_modules/markdown-it/lib/rules_block/fence.mjs +4 -4
  143. package/node_modules/markdown-it/lib/rules_block/heading.mjs +7 -7
  144. package/node_modules/markdown-it/lib/rules_block/hr.mjs +2 -2
  145. package/node_modules/markdown-it/lib/rules_block/html_block.mjs +6 -6
  146. package/node_modules/markdown-it/lib/rules_block/lheading.mjs +8 -8
  147. package/node_modules/markdown-it/lib/rules_block/list.mjs +6 -6
  148. package/node_modules/markdown-it/lib/rules_block/paragraph.mjs +5 -5
  149. package/node_modules/markdown-it/lib/rules_block/reference.mjs +1 -1
  150. package/node_modules/markdown-it/lib/rules_block/state_block.mjs +6 -6
  151. package/node_modules/markdown-it/lib/rules_block/table.mjs +4 -4
  152. package/node_modules/markdown-it/lib/rules_core/block.mjs +3 -3
  153. package/node_modules/markdown-it/lib/rules_core/linkify.mjs +46 -20
  154. package/node_modules/markdown-it/lib/rules_core/normalize.mjs +2 -2
  155. package/node_modules/markdown-it/lib/rules_core/smartquotes.mjs +48 -27
  156. package/node_modules/markdown-it/lib/rules_inline/autolink.mjs +17 -17
  157. package/node_modules/markdown-it/lib/rules_inline/balance_pairs.mjs +2 -2
  158. package/node_modules/markdown-it/lib/rules_inline/emphasis.mjs +8 -8
  159. package/node_modules/markdown-it/lib/rules_inline/entity.mjs +7 -7
  160. package/node_modules/markdown-it/lib/rules_inline/escape.mjs +15 -1
  161. package/node_modules/markdown-it/lib/rules_inline/html_inline.mjs +1 -1
  162. package/node_modules/markdown-it/lib/rules_inline/link.mjs +1 -1
  163. package/node_modules/markdown-it/lib/rules_inline/linkify.mjs +27 -9
  164. package/node_modules/markdown-it/lib/rules_inline/state_inline.mjs +2 -2
  165. package/node_modules/markdown-it/lib/rules_inline/strikethrough.mjs +10 -10
  166. package/node_modules/markdown-it/lib/token.mjs +12 -12
  167. package/node_modules/markdown-it/package.json +27 -34
  168. package/node_modules/nan/.github/workflows/ci.yml +46 -0
  169. package/node_modules/nan/.pre-commit-config.yaml +8 -0
  170. package/node_modules/nan/CHANGELOG.md +56 -1
  171. package/node_modules/nan/README.md +7 -6
  172. package/node_modules/nan/doc/methods.md +17 -0
  173. package/node_modules/nan/doc/string_bytes.md +19 -0
  174. package/node_modules/nan/doc/v8_internals.md +16 -4
  175. package/node_modules/nan/nan.h +274 -26
  176. package/node_modules/nan/nan_callbacks.h +50 -1
  177. package/node_modules/nan/nan_callbacks_12_inl.h +294 -50
  178. package/node_modules/nan/nan_callbacks_pre_12_inl.h +10 -2
  179. package/node_modules/nan/nan_implementation_12_inl.h +19 -3
  180. package/node_modules/nan/nan_maybe_43_inl.h +7 -2
  181. package/node_modules/nan/nan_maybe_pre_43_inl.h +1 -1
  182. package/node_modules/nan/nan_scriptorigin.h +22 -1
  183. package/node_modules/nan/nan_typedarray_contents.h +1 -1
  184. package/node_modules/nan/nan_weak.h +16 -0
  185. package/node_modules/nan/package.json +5 -5
  186. package/package.json +16 -14
@@ -6,6 +6,19 @@ import { isWhiteSpace, isPunctCharCode, isMdAsciiPunct } from '../common/utils.m
6
6
  const QUOTE_TEST_RE = /['"]/
7
7
  const QUOTE_RE = /['"]/g
8
8
  const APOSTROPHE = '\u2019' /* ’ */
9
+ // Caps memory on malicious input
10
+ const MAX_OPENERS = 1000
11
+
12
+ function truncateStack (stack, heads, length) {
13
+ while (stack.length > length) {
14
+ const item = stack.pop()
15
+ if (item.isSingleQuote) {
16
+ heads.single = item.prevSameQuoteIdx
17
+ } else {
18
+ heads.double = item.prevSameQuoteIdx
19
+ }
20
+ }
21
+ }
9
22
 
10
23
  function addReplacement (replacements, tokenIdx, pos, ch) {
11
24
  if (!replacements[tokenIdx]) {
@@ -35,6 +48,8 @@ function process_inlines (tokens, state) {
35
48
  let j
36
49
 
37
50
  const stack = []
51
+ // stack indexes of topmost openers of each type (-1 if none)
52
+ const heads = { single: -1, double: -1 }
38
53
  // token index -> list of replacements in the original token content
39
54
  const replacements = {}
40
55
 
@@ -46,7 +61,7 @@ function process_inlines (tokens, state) {
46
61
  for (j = stack.length - 1; j >= 0; j--) {
47
62
  if (stack[j].level <= thisLevel) { break }
48
63
  }
49
- stack.length = j + 1
64
+ truncateStack(stack, heads, j + 1)
50
65
 
51
66
  if (token.type !== 'text') { continue }
52
67
 
@@ -150,39 +165,45 @@ function process_inlines (tokens, state) {
150
165
  }
151
166
 
152
167
  if (canClose) {
153
- // this could be a closing quote, rewind the stack to get a match
154
- for (j = stack.length - 1; j >= 0; j--) {
155
- let item = stack[j]
156
- if (stack[j].level < thisLevel) { break }
157
- if (item.single === isSingle && stack[j].level === thisLevel) {
158
- item = stack[j]
159
-
160
- let openQuote
161
- let closeQuote
162
- if (isSingle) {
163
- openQuote = state.md.options.quotes[2]
164
- closeQuote = state.md.options.quotes[3]
165
- } else {
166
- openQuote = state.md.options.quotes[0]
167
- closeQuote = state.md.options.quotes[1]
168
- }
169
-
170
- addReplacement(replacements, i, t.index, closeQuote)
171
- addReplacement(replacements, item.token, item.pos, openQuote)
172
-
173
- stack.length = j
174
- continue OUTER
168
+ // Stack levels never decrease, so an opener of this type below
169
+ // the current level means there is no match
170
+ j = isSingle ? heads.single : heads.double
171
+ if (j >= 0 && stack[j].level === thisLevel) {
172
+ const item = stack[j]
173
+
174
+ let openQuote
175
+ let closeQuote
176
+ if (isSingle) {
177
+ openQuote = state.md.options.quotes[2]
178
+ closeQuote = state.md.options.quotes[3]
179
+ } else {
180
+ openQuote = state.md.options.quotes[0]
181
+ closeQuote = state.md.options.quotes[1]
175
182
  }
183
+
184
+ addReplacement(replacements, i, t.index, closeQuote)
185
+ addReplacement(replacements, item.tokenIdx, item.contentPos, openQuote)
186
+
187
+ truncateStack(stack, heads, j)
188
+ continue OUTER
176
189
  }
177
190
  }
178
191
 
179
192
  if (canOpen) {
193
+ if (stack.length >= MAX_OPENERS) { return }
180
194
  stack.push({
181
- token: i,
182
- pos: t.index,
183
- single: isSingle,
184
- level: thisLevel
195
+ tokenIdx: i,
196
+ contentPos: t.index,
197
+ isSingleQuote: isSingle,
198
+ level: thisLevel,
199
+ // stack index of the previous opener of the same quote type, -1 if none
200
+ prevSameQuoteIdx: isSingle ? heads.single : heads.double
185
201
  })
202
+ if (isSingle) {
203
+ heads.single = stack.length - 1
204
+ } else {
205
+ heads.double = stack.length - 1
206
+ }
186
207
  } else if (canClose && isSingle) {
187
208
  addReplacement(replacements, i, t.index, APOSTROPHE)
188
209
  }
@@ -1,7 +1,7 @@
1
1
  // Process autolinks '<protocol:...>'
2
2
 
3
3
  /* eslint max-len:0 */
4
- const EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/
4
+ const EMAIL_RE = /^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/
5
5
  /* eslint-disable-next-line no-control-regex */
6
6
  const AUTOLINK_RE = /^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/
7
7
 
@@ -29,17 +29,17 @@ export default function autolink (state, silent) {
29
29
  if (!state.md.validateLink(fullUrl)) { return false }
30
30
 
31
31
  if (!silent) {
32
- const token_o = state.push('link_open', 'a', 1)
33
- token_o.attrs = [['href', fullUrl]]
34
- token_o.markup = 'autolink'
35
- token_o.info = 'auto'
32
+ const token_o = state.push('link_open', 'a', 1)
33
+ token_o.attrs = [['href', fullUrl]]
34
+ token_o.markup = 'autolink'
35
+ token_o.info = 'auto'
36
36
 
37
- const token_t = state.push('text', '', 0)
37
+ const token_t = state.push('text', '', 0)
38
38
  token_t.content = state.md.normalizeLinkText(url)
39
39
 
40
- const token_c = state.push('link_close', 'a', -1)
41
- token_c.markup = 'autolink'
42
- token_c.info = 'auto'
40
+ const token_c = state.push('link_close', 'a', -1)
41
+ token_c.markup = 'autolink'
42
+ token_c.info = 'auto'
43
43
  }
44
44
 
45
45
  state.pos += url.length + 2
@@ -51,17 +51,17 @@ export default function autolink (state, silent) {
51
51
  if (!state.md.validateLink(fullUrl)) { return false }
52
52
 
53
53
  if (!silent) {
54
- const token_o = state.push('link_open', 'a', 1)
55
- token_o.attrs = [['href', fullUrl]]
56
- token_o.markup = 'autolink'
57
- token_o.info = 'auto'
54
+ const token_o = state.push('link_open', 'a', 1)
55
+ token_o.attrs = [['href', fullUrl]]
56
+ token_o.markup = 'autolink'
57
+ token_o.info = 'auto'
58
58
 
59
- const token_t = state.push('text', '', 0)
59
+ const token_t = state.push('text', '', 0)
60
60
  token_t.content = state.md.normalizeLinkText(url)
61
61
 
62
- const token_c = state.push('link_close', 'a', -1)
63
- token_c.markup = 'autolink'
64
- token_c.info = 'auto'
62
+ const token_c = state.push('link_close', 'a', -1)
63
+ token_c.markup = 'autolink'
64
+ token_c.info = 'auto'
65
65
  }
66
66
 
67
67
  state.pos += url.length + 2
@@ -85,8 +85,8 @@ function processDelimiters (delimiters) {
85
85
  jumps[closerIdx] = closerIdx - openerIdx + lastJump
86
86
  jumps[openerIdx] = lastJump
87
87
 
88
- closer.open = false
89
- opener.end = closerIdx
88
+ closer.open = false
89
+ opener.end = closerIdx
90
90
  opener.close = false
91
91
  newMinOpenerIdx = -1
92
92
  // treat next token as start of run,
@@ -80,18 +80,18 @@ function postProcess (state, delimiters) {
80
80
 
81
81
  const ch = String.fromCharCode(startDelim.marker)
82
82
 
83
- const token_o = state.tokens[startDelim.token]
84
- token_o.type = isStrong ? 'strong_open' : 'em_open'
85
- token_o.tag = isStrong ? 'strong' : 'em'
83
+ const token_o = state.tokens[startDelim.token]
84
+ token_o.type = isStrong ? 'strong_open' : 'em_open'
85
+ token_o.tag = isStrong ? 'strong' : 'em'
86
86
  token_o.nesting = 1
87
- token_o.markup = isStrong ? ch + ch : ch
87
+ token_o.markup = isStrong ? ch + ch : ch
88
88
  token_o.content = ''
89
89
 
90
- const token_c = state.tokens[endDelim.token]
91
- token_c.type = isStrong ? 'strong_close' : 'em_close'
92
- token_c.tag = isStrong ? 'strong' : 'em'
90
+ const token_c = state.tokens[endDelim.token]
91
+ token_c.type = isStrong ? 'strong_close' : 'em_close'
92
+ token_c.tag = isStrong ? 'strong' : 'em'
93
93
  token_c.nesting = -1
94
- token_c.markup = isStrong ? ch + ch : ch
94
+ token_c.markup = isStrong ? ch + ch : ch
95
95
  token_c.content = ''
96
96
 
97
97
  if (isStrong) {
@@ -4,7 +4,7 @@ import { decodeHTMLStrict } from 'entities'
4
4
  import { isValidEntityCode, fromCodePoint } from '../common/utils.mjs'
5
5
 
6
6
  const DIGITAL_RE = /^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i
7
- const NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i
7
+ const NAMED_RE = /^&([a-z][a-z0-9]{1,31});/i
8
8
 
9
9
  export default function entity (state, silent) {
10
10
  const pos = state.pos
@@ -22,10 +22,10 @@ export default function entity (state, silent) {
22
22
  if (!silent) {
23
23
  const code = match[1][0].toLowerCase() === 'x' ? parseInt(match[1].slice(1), 16) : parseInt(match[1], 10)
24
24
 
25
- const token = state.push('text_special', '', 0)
25
+ const token = state.push('text_special', '', 0)
26
26
  token.content = isValidEntityCode(code) ? fromCodePoint(code) : fromCodePoint(0xFFFD)
27
- token.markup = match[0]
28
- token.info = 'entity'
27
+ token.markup = match[0]
28
+ token.info = 'entity'
29
29
  }
30
30
  state.pos += match[0].length
31
31
  return true
@@ -36,10 +36,10 @@ export default function entity (state, silent) {
36
36
  const decoded = decodeHTMLStrict(match[0])
37
37
  if (decoded !== match[0]) {
38
38
  if (!silent) {
39
- const token = state.push('text_special', '', 0)
39
+ const token = state.push('text_special', '', 0)
40
40
  token.content = decoded
41
- token.markup = match[0]
42
- token.info = 'entity'
41
+ token.markup = match[0]
42
+ token.info = 'entity'
43
43
  }
44
44
  state.pos += match[0].length
45
45
  return true
@@ -38,6 +38,20 @@ export default function escape (state, silent) {
38
38
  return true
39
39
  }
40
40
 
41
+ // '\' before a space is a literal backslash. Don't consume the space, so a
42
+ // trailing two-space hard line break is still detected by the newline rule.
43
+ if (ch1 === 0x20) {
44
+ if (!silent) {
45
+ const token = state.push('text_special', '', 0)
46
+ token.content = '\\'
47
+ token.markup = '\\'
48
+ token.info = 'escape'
49
+ }
50
+
51
+ state.pos = pos
52
+ return true
53
+ }
54
+
41
55
  let escapedStr = state.src[pos]
42
56
 
43
57
  if (ch1 >= 0xD800 && ch1 <= 0xDBFF && pos + 1 < max) {
@@ -61,7 +75,7 @@ export default function escape (state, silent) {
61
75
  }
62
76
 
63
77
  token.markup = origStr
64
- token.info = 'escape'
78
+ token.info = 'escape'
65
79
  }
66
80
 
67
81
  state.pos = pos + 1
@@ -42,7 +42,7 @@ export default function html_inline (state, silent) {
42
42
  const token = state.push('html_inline', '', 0)
43
43
  token.content = match[0]
44
44
 
45
- if (isLinkOpen(token.content)) state.linkLevel++
45
+ if (isLinkOpen(token.content)) state.linkLevel++
46
46
  if (isLinkClose(token.content)) state.linkLevel--
47
47
  }
48
48
  state.pos += match[0].length
@@ -121,7 +121,7 @@ export default function link (state, silent) {
121
121
 
122
122
  const token_o = state.push('link_open', 'a', 1)
123
123
  const attrs = [['href', href]]
124
- token_o.attrs = attrs
124
+ token_o.attrs = attrs
125
125
  if (title) {
126
126
  attrs.push(['title', title])
127
127
  }
@@ -1,7 +1,17 @@
1
- // Process links like https://example.org/
1
+ // Early process links like https://example.org/ to have priority
2
+ // over emphasis, etc.
2
3
 
3
4
  // RFC3986: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
4
- const SCHEME_RE = /(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i
5
+ function isAsciiAlpha (code) {
6
+ return (code >= 0x41 && code <= 0x5A) || (code >= 0x61 && code <= 0x7A)
7
+ }
8
+
9
+ function isSchemeChar (code) {
10
+ return (code >= 0x41 && code <= 0x5A) ||
11
+ (code >= 0x61 && code <= 0x7A) ||
12
+ (code >= 0x30 && code <= 0x39) ||
13
+ code === 0x2B || code === 0x2D || code === 0x2E
14
+ }
5
15
 
6
16
  export default function linkify (state, silent) {
7
17
  if (!state.md.options.linkify) return false
@@ -15,19 +25,27 @@ export default function linkify (state, silent) {
15
25
  if (state.src.charCodeAt(pos + 1) !== 0x2F/* / */) return false
16
26
  if (state.src.charCodeAt(pos + 2) !== 0x2F/* / */) return false
17
27
 
18
- const match = state.pending.match(SCHEME_RE)
19
- if (!match) return false
28
+ // Search backwards for the scheme, but no more than 10 characters, the length
29
+ // of the pending string, or the length of the source prefix.
30
+ // Use state.src instead of state.pending because it is faster to access.
31
+ const protoMin = pos - Math.min(10, state.pending.length, pos)
32
+ let protoStart = pos
33
+ while (protoStart > protoMin && isSchemeChar(state.src.charCodeAt(protoStart - 1))) {
34
+ protoStart--
35
+ }
36
+
37
+ if (protoStart === pos || !isAsciiAlpha(state.src.charCodeAt(protoStart))) return false
20
38
 
21
- const proto = match[1]
39
+ const protoLength = pos - protoStart
22
40
 
23
- const link = state.md.linkify.matchAtStart(state.src.slice(pos - proto.length))
41
+ const link = state.md.linkify.matchAtStart(state.src.slice(protoStart))
24
42
  if (!link) return false
25
43
 
26
44
  let url = link.url
27
45
 
28
46
  // invalid link, but still detected by linkify somehow;
29
47
  // need to check to prevent infinite loop below
30
- if (url.length <= proto.length) return false
48
+ if (url.length <= protoLength) return false
31
49
 
32
50
  // disallow '*' at the end of the link (conflicts with emphasis)
33
51
  // do manual backsearch to avoid perf issues with regex /\*+$/ on "****...****a".
@@ -43,7 +61,7 @@ export default function linkify (state, silent) {
43
61
  if (!state.md.validateLink(fullUrl)) return false
44
62
 
45
63
  if (!silent) {
46
- state.pending = state.pending.slice(0, -proto.length)
64
+ state.pending = state.pending.slice(0, -protoLength)
47
65
 
48
66
  const token_o = state.push('link_open', 'a', 1)
49
67
  token_o.attrs = [['href', fullUrl]]
@@ -58,6 +76,6 @@ export default function linkify (state, silent) {
58
76
  token_c.info = 'auto'
59
77
  }
60
78
 
61
- state.pos += url.length - proto.length
79
+ state.pos += url.length - protoLength
62
80
  return true
63
81
  }
@@ -142,8 +142,8 @@ StateInline.prototype.scanDelims = function (start, canSplitWord) {
142
142
  const right_flanking =
143
143
  !isLastWhiteSpace && (!isLastPunctChar || isNextWhiteSpace || isNextPunctChar)
144
144
 
145
- const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar)
146
- const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar)
145
+ const can_open = left_flanking && (canSplitWord || !right_flanking || isLastPunctChar)
146
+ const can_close = right_flanking && (canSplitWord || !left_flanking || isNextPunctChar)
147
147
 
148
148
  return { can_open, can_close, length: count }
149
149
  }
@@ -20,13 +20,13 @@ function strikethrough_tokenize (state, silent) {
20
20
  let token
21
21
 
22
22
  if (len % 2) {
23
- token = state.push('text', '', 0)
23
+ token = state.push('text', '', 0)
24
24
  token.content = ch
25
25
  len--
26
26
  }
27
27
 
28
28
  for (let i = 0; i < len; i += 2) {
29
- token = state.push('text', '', 0)
29
+ token = state.push('text', '', 0)
30
30
  token.content = ch + ch
31
31
 
32
32
  state.delimiters.push({
@@ -62,18 +62,18 @@ function postProcess (state, delimiters) {
62
62
 
63
63
  const endDelim = delimiters[startDelim.end]
64
64
 
65
- token = state.tokens[startDelim.token]
66
- token.type = 's_open'
67
- token.tag = 's'
65
+ token = state.tokens[startDelim.token]
66
+ token.type = 's_open'
67
+ token.tag = 's'
68
68
  token.nesting = 1
69
- token.markup = '~~'
69
+ token.markup = '~~'
70
70
  token.content = ''
71
71
 
72
- token = state.tokens[endDelim.token]
73
- token.type = 's_close'
74
- token.tag = 's'
72
+ token = state.tokens[endDelim.token]
73
+ token.type = 's_close'
74
+ token.tag = 's'
75
75
  token.nesting = -1
76
- token.markup = '~~'
76
+ token.markup = '~~'
77
77
  token.content = ''
78
78
 
79
79
  if (state.tokens[endDelim.token - 1].type === 'text' &&
@@ -15,28 +15,28 @@ function Token (type, tag, nesting) {
15
15
  *
16
16
  * Type of the token (string, e.g. "paragraph_open")
17
17
  **/
18
- this.type = type
18
+ this.type = type
19
19
 
20
20
  /**
21
21
  * Token#tag -> String
22
22
  *
23
23
  * html tag name, e.g. "p"
24
24
  **/
25
- this.tag = tag
25
+ this.tag = tag
26
26
 
27
27
  /**
28
28
  * Token#attrs -> Array
29
29
  *
30
30
  * Html attributes. Format: `[ [ name1, value1 ], [ name2, value2 ] ]`
31
31
  **/
32
- this.attrs = null
32
+ this.attrs = null
33
33
 
34
34
  /**
35
35
  * Token#map -> Array
36
36
  *
37
37
  * Source map info. Format: `[ line_begin, line_end ]`
38
38
  **/
39
- this.map = null
39
+ this.map = null
40
40
 
41
41
  /**
42
42
  * Token#nesting -> Number
@@ -47,14 +47,14 @@ function Token (type, tag, nesting) {
47
47
  * - `0` means the tag is self-closing
48
48
  * - `-1` means the tag is closing
49
49
  **/
50
- this.nesting = nesting
50
+ this.nesting = nesting
51
51
 
52
52
  /**
53
53
  * Token#level -> Number
54
54
  *
55
55
  * nesting level, the same as `state.level`
56
56
  **/
57
- this.level = 0
57
+ this.level = 0
58
58
 
59
59
  /**
60
60
  * Token#children -> Array
@@ -69,14 +69,14 @@ function Token (type, tag, nesting) {
69
69
  * In a case of self-closing tag (code, html, fence, etc.),
70
70
  * it has contents of this tag.
71
71
  **/
72
- this.content = ''
72
+ this.content = ''
73
73
 
74
74
  /**
75
75
  * Token#markup -> String
76
76
  *
77
77
  * '*' or '_' for emphasis, fence string for fence, etc.
78
78
  **/
79
- this.markup = ''
79
+ this.markup = ''
80
80
 
81
81
  /**
82
82
  * Token#info -> String
@@ -87,14 +87,14 @@ function Token (type, tag, nesting) {
87
87
  * - The value "auto" for autolink "link_open" and "link_close" tokens
88
88
  * - The string value of the item marker for ordered-list "list_item_open" tokens
89
89
  **/
90
- this.info = ''
90
+ this.info = ''
91
91
 
92
92
  /**
93
93
  * Token#meta -> Object
94
94
  *
95
95
  * A place for plugins to store an arbitrary data
96
96
  **/
97
- this.meta = null
97
+ this.meta = null
98
98
 
99
99
  /**
100
100
  * Token#block -> Boolean
@@ -102,7 +102,7 @@ function Token (type, tag, nesting) {
102
102
  * True for block-level tokens, false for inline tokens.
103
103
  * Used in renderer to calculate line breaks
104
104
  **/
105
- this.block = false
105
+ this.block = false
106
106
 
107
107
  /**
108
108
  * Token#hidden -> Boolean
@@ -110,7 +110,7 @@ function Token (type, tag, nesting) {
110
110
  * If it's true, ignore this element when rendering. Used for tight lists
111
111
  * to hide paragraphs.
112
112
  **/
113
- this.hidden = false
113
+ this.hidden = false
114
114
  }
115
115
 
116
116
  /**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markdown-it",
3
- "version": "14.2.0",
3
+ "version": "14.3.2",
4
4
  "description": "Markdown-it - modern pluggable markdown parser.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -38,49 +38,47 @@
38
38
  },
39
39
  "scripts": {
40
40
  "lint": "eslint .",
41
- "test": "npm run lint && cross-env CJS_ONLY=1 npm run build && c8 --exclude dist --exclude test -r text -r html -r lcov mocha && node support/specsplit.mjs",
41
+ "test": "npm run lint && npm run test:cmspec && npm run test:markdown-it && npm run test:build",
42
+ "test:cmspec": "node --test --test-reporter=dot test/cmspec/**/*.test.mjs",
43
+ "test:markdown-it": "node --test test/markdown-it/**/*.test.mjs",
44
+ "test:build": "npm run build && node --test test/build/**/*.test.mjs",
45
+ "pathological:track-ref": "node support/track-ref-pathological.mjs",
46
+ "pathological:update-hash": "node support/track-ref-pathological.mjs --update",
47
+ "coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test --test-reporter=dot",
42
48
  "doc": "node support/build_doc.mjs",
43
49
  "gh-doc": "npm run doc && gh-pages -d apidoc -f",
44
50
  "demo": "npm run lint && node support/build_demo.mjs",
45
51
  "gh-demo": "npm run demo && gh-pages -d demo -f -b master -r git@github.com:markdown-it/markdown-it.github.io.git",
46
- "build": "rollup -c support/rollup.config.mjs",
47
- "benchmark-deps": "npm install --prefix benchmark/extra/ -g marked@0.3.6 commonmark@0.26.0 markdown-it/markdown-it.git#2.2.1",
52
+ "build": "node support/build-dist.mjs",
53
+ "benchmark-deps": "npm install --prefix benchmark/extra/",
48
54
  "specsplit": "support/specsplit.mjs good -o test/fixtures/commonmark/good.txt && support/specsplit.mjs bad -o test/fixtures/commonmark/bad.txt && support/specsplit.mjs",
49
55
  "todo": "grep 'TODO' -n -r ./lib 2>/dev/null",
50
- "prepublishOnly": "npm test && npm run build && npm run gh-demo && npm run gh-doc"
56
+ "prepack": "npm test && npm run build"
51
57
  },
52
58
  "files": [
53
59
  "index.mjs",
54
60
  "lib/",
55
61
  "dist/"
56
62
  ],
63
+ "publishConfig": {
64
+ "tag": "v14-legacy"
65
+ },
57
66
  "dependencies": {
58
67
  "argparse": "^2.0.1",
59
- "entities": "^4.4.0",
60
- "linkify-it": "^5.0.1",
68
+ "entities": "^4.5.0",
69
+ "linkify-it": "^5.0.2",
61
70
  "mdurl": "^2.0.0",
62
71
  "punycode.js": "^2.3.1",
63
72
  "uc.micro": "^2.1.0"
64
73
  },
65
74
  "devDependencies": {
66
- "@rollup/plugin-babel": "^6.0.4",
67
- "@rollup/plugin-commonjs": "^25.0.7",
68
- "@rollup/plugin-node-resolve": "^15.2.3",
69
- "@rollup/plugin-terser": "^0.4.4",
70
- "ansi": "^0.3.0",
71
- "benchmark": "~2.1.0",
72
- "c8": "^8.0.1",
73
- "chai": "^4.2.0",
74
- "cross-env": "^7.0.3",
75
- "eslint": "^8.4.1",
76
- "eslint-config-standard": "^17.1.0",
77
- "express": "^4.14.0",
78
- "gh-pages": "^6.1.0",
79
- "highlight.js": "^11.9.0",
80
- "jest-worker": "^29.7.0",
75
+ "c8": "^11.0.0",
76
+ "eslint": "^9.39.4",
77
+ "gh-pages": "^6.3.0",
78
+ "highlight.js": "^11.11.1",
81
79
  "markdown-it-abbr": "^2.0.0",
82
80
  "markdown-it-container": "^4.0.0",
83
- "markdown-it-deflist": "^3.0.0",
81
+ "markdown-it-deflist": "^3.0.1",
84
82
  "markdown-it-emoji": "^3.0.0",
85
83
  "markdown-it-footnote": "^4.0.0",
86
84
  "markdown-it-for-inline": "^2.0.1",
@@ -88,16 +86,11 @@
88
86
  "markdown-it-mark": "^4.0.0",
89
87
  "markdown-it-sub": "^2.0.0",
90
88
  "markdown-it-sup": "^2.0.0",
91
- "markdown-it-testgen": "^0.1.3",
92
- "mocha": "^10.2.0",
93
- "ndoc": "^6.0.0",
94
- "needle": "^3.0.0",
95
- "rollup": "^4.5.0",
96
- "shelljs": "^0.8.4",
97
- "supertest": "^6.0.1"
98
- },
99
- "mocha": {
100
- "inline-diffs": true,
101
- "timeout": 60000
89
+ "ndoc": "^6.0.1",
90
+ "neostandard": "^0.13.0",
91
+ "terser": "^5.48.0",
92
+ "tinybench": "^6.0.2",
93
+ "vite": "^8.1.2",
94
+ "vite-plugin-singlefile": "^2.3.3"
102
95
  }
103
96
  }