Repository navigation
Commit 5e0ea99
Don't link URLs with unsafe schemes in
`{click}[javascript:alert(1)]` and `[click](javascript:alert(1))` were
rendered as `<a href="javascript:alert(1)">`. The test added for this in
#933 checked the input string instead
of the converted result, so it always passed.
`gen_url` now renders only the link text when the resolved URL has a
`javascript:`, `vbscript:`, `data:` or `file:` scheme, the same schemes
cmark and markdown-it reject:
*
https://github.com/commonmark/cmark/blob/6566d91bdb25898bd910f8bed2a3f18f4a05cf91/src/scanners.re#L322-L332
*
https://github.com/markdown-it/markdown-it/blob/3c51991c32aaa2b002a52c009334ebe5752c84b3/src/markdownit.ts#L60-L61
The check is done after `parse_url` so that `link:javascript:...` is
also caught, and ignores leading C0 controls and spaces and ASCII tabs
and newlines like browsers do:
* https://url.spec.whatwg.org/#concept-basic-url-parser
Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>Markup::ToHtml (#1832)1 parent 4355a42 commit 5e0ea99
2 files changed
Lines changed: 52 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
151 | 157 | | |
152 | 158 | | |
153 | 159 | | |
| |||
605 | 611 | | |
606 | 612 | | |
607 | 613 | | |
| 614 | + | |
| 615 | + | |
608 | 616 | | |
609 | 617 | | |
610 | 618 | | |
611 | 619 | | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
612 | 623 | | |
613 | 624 | | |
614 | 625 | | |
| |||
629 | 640 | | |
630 | 641 | | |
631 | 642 | | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
632 | 656 | | |
633 | 657 | | |
634 | 658 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
931 | 931 | | |
932 | 932 | | |
933 | 933 | | |
934 | | - | |
| 934 | + | |
| 935 | + | |
935 | 936 | | |
936 | 937 | | |
937 | 938 | | |
| |||
959 | 960 | | |
960 | 961 | | |
961 | 962 | | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
962 | 989 | | |
963 | 990 | | |
964 | 991 | | |
| |||
0 commit comments