@peaceroad/markdown-it-strong-ja 0.4.3 → 0.4.4

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 (2) hide show
  1. package/index.js +20 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -168,7 +168,21 @@ const createInlines = (state, start, max, opt) => {
168
168
  let noMark = ''
169
169
  let textStart = n
170
170
 
171
+ // Infinite loop prevention
172
+ const maxIterations = srcLen * 2 // Safe upper bound
173
+ let iterations = 0
174
+
171
175
  while (n < srcLen) {
176
+ // Prevent infinite loops
177
+ iterations++
178
+ if (iterations > maxIterations) {
179
+ // Add remaining text as-is and exit safely
180
+ if (textStart < srcLen) {
181
+ pushInlines(inlines, textStart, srcLen - 1, srcLen - textStart, 'text')
182
+ }
183
+ break
184
+ }
185
+
172
186
  const currentChar = src.charCodeAt(n)
173
187
  let nextSymbolPos = -1
174
188
 
@@ -200,6 +214,7 @@ const createInlines = (state, start, max, opt) => {
200
214
 
201
215
  // HTML tags
202
216
  if (htmlEnabled && currentChar === CHAR_LT && !hasBackslash(state, n)) {
217
+ let foundClosingTag = false
203
218
  for (let i = n + 1; i < srcLen; i++) {
204
219
  if (src.charCodeAt(i) === CHAR_GT && !hasBackslash(state, i)) {
205
220
  if (noMark.length !== 0) {
@@ -217,10 +232,14 @@ const createInlines = (state, start, max, opt) => {
217
232
  pushInlines(inlines, n, i, i - n + 1, 'html_inline', tag, tagType)
218
233
  textStart = i + 1
219
234
  n = i + 1
235
+ foundClosingTag = true
220
236
  break
221
237
  }
222
238
  }
223
- continue
239
+ if (foundClosingTag) {
240
+ continue
241
+ }
242
+ // If no closing tag found, treat as regular character to prevent infinite loops
224
243
  }
225
244
 
226
245
  // Asterisk handling
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@peaceroad/markdown-it-strong-ja",
3
3
  "description": "This is a plugin for markdown-it. It is an alternative to the standard `**` (strong) and `*` (em) processing. It also processes strings that cannot be converted by the standard.",
4
- "version": "0.4.3",
4
+ "version": "0.4.4",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "files": [