瀏覽代碼

fix: fix non-breaking space in link url (#3667)

Tony Brix 4 月之前
父節點
當前提交
e071e25d13
共有 3 個文件被更改,包括 4 次插入6 次删除
  1. 2 2
      src/rules.ts
  2. 1 2
      test/specs/commonmark/commonmark.0.31.2.json
  3. 1 2
      test/specs/gfm/commonmark.0.31.2.json

+ 2 - 2
src/rules.ts

@@ -338,9 +338,9 @@ const tag = edit(
 
 const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
 
-const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/)
+const link = edit(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/)
   .replace('label', _inlineLabel)
-  .replace('href', /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/)
+  .replace('href', /<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/)
   .replace('title', /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/)
   .getRegex();
 

+ 1 - 2
test/specs/commonmark/commonmark.0.31.2.json

@@ -4056,8 +4056,7 @@
     "example": 507,
     "start_line": 7776,
     "end_line": 7780,
-    "section": "Links",
-    "shouldFail": true
+    "section": "Links"
   },
   {
     "markdown": "[link](/url \"title \"and\" title\")\n",

+ 1 - 2
test/specs/gfm/commonmark.0.31.2.json

@@ -4056,8 +4056,7 @@
     "example": 507,
     "start_line": 7776,
     "end_line": 7780,
-    "section": "Links",
-    "shouldFail": true
+    "section": "Links"
   },
   {
     "markdown": "[link](/url \"title \"and\" title\")\n",