Behaviour SwRS-MDOKFSTUDIO-GFM-001
Bare URLs become safe links
When prose contains a bare http://, https:// or www. URL, the extension SHALL render it as a link that follows the Markdown link policy, opening www. URLs as https://, leaving trailing sentence punctuation and unbalanced closing parentheses outside the link, and leaving unlinked any text that has another meaning or another scheme.
Step 1 of path 1 in StRS-MDOKFSTUDIO-GFM-002: from “Prose holds a bare URL” to “The URL is a link, and the prose holds struck text, a footnote or a pipe table”.
Scenarios 7
The situations the tests check; open one to read it.
nominalBare URLs in prose, lists and tables
Givena paragraph, a list item and a table cell each containing https://example.com and www.example.com
Whenthe preview is rendered
Theneach URL is a link and the www. link targets https://www.example.com
boundaryTrailing punctuation stays outside the link
| Input | Outcome |
|---|---|
| `see https://example.com/a.` | the link ends before the final period |
| `(https://example.com/a_(b))` | the link keeps the balanced parentheses of a_(b) and ends before the last closing parenthesis |
| `(see https://example.com/a)` | the closing parenthesis is outside the link |
refusalText with a meaning is not autolinked
| Input | Outcome |
|---|---|
| inline code, a fenced block and a Markdown link each containing https://example.com | no additional link is created and the code text is unchanged |
| https://example.com in math, raw HTML, an image, a reference or an e-mail address | no link is created |
| a directive option line containing https://example.com | the option text stays literal and no link is created |
| `abchttps://example.com` (glued to a word character) | not a link |
| `a@example.com` | not a link |
refusalOnly http, https and www hosts are autolinked
| Input | Outcome |
|---|---|
| `javascript:alert(1)` | stays plain text |
| `ftp://example.com` | stays plain text |
| `data:` and `vbscript:` text | no link is created |
| `www.` and `www.localhost` (no dotted host) | no link is created |
nominalAutolinks follow the Markdown link policy
Givena bare https://example.com URL, and a bare URL whose generated link the sanitizer would reject
Whenthe rendered HTML is sanitized
Thenthe first link carries the same attributes and navigation routing as [x](https://example.com), and the rejected link is removed exactly as for a Markdown link
nominalThe block editor shows the raw URL
Givena paragraph 'visit https://example.com now', and a paragraph with www.example.com
Whenthe block editor source is requested
Thenthe text equals the original source, so the www.example.com paragraph still reads www.example.com and not an https:// link
boundaryPathological URLs render in linear time
| Input | Outcome |
|---|---|
| a 100 000-character URL | rendering completes in under 1 s |
| a URL followed by 50 000 closing parentheses | rendering completes in under 1 s and the link ends at the balanced position |
Implemented in 1
Tested by 1
Replaces
SwRS-MDOKFSTUDIO-GFM-002Trailing punctuation stays outside bare URLs superseded superseded by SwRS-MDOKFSTUDIO-GFM-001 Markdown file
SwRS-MDOKFSTUDIO-GFM-003Text with a meaning is not autolinked superseded superseded by SwRS-MDOKFSTUDIO-GFM-001 Markdown file
SwRS-MDOKFSTUDIO-GFM-004Only http, https and www hosts are autolinked superseded superseded by SwRS-MDOKFSTUDIO-GFM-001 Markdown file
SwRS-MDOKFSTUDIO-GFM-005Autolinks follow the Markdown link policy superseded superseded by SwRS-MDOKFSTUDIO-GFM-001 Markdown file
SwRS-MDOKFSTUDIO-GFM-006Editing an autolink shows the raw URL superseded superseded by SwRS-MDOKFSTUDIO-GFM-001 Markdown file
SwRS-MDOKFSTUDIO-GFM-007Pathological URLs render in linear time superseded superseded by SwRS-MDOKFSTUDIO-GFM-001 Markdown file