akiomik / akiomik/mado

MD034 reports a URL that GFM does not autolink

Ouverte
#408 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
bug
Langage dominant
Rust
Étoiles
409
Forks
12
Merge moyen
5 h 45 min
PR mergées (30 j)
30

Description

MD034 reports a URL whose scheme carries a backslash escape, and GFM does not
autolink one:

```markdown
For more information, see http\://www.example.com/.
```

is reported as a bare URL, where comrak with the autolink extension renders

```html

For more information, see http://www.example.com/.


```

An escape written into the scheme is how a URL is spelled so that it is *not*
autolinked, which is the opposite of what the rule is for.

## Cause

The rule scans a text node's `literal`, which is what `CommonMark` renders and
so is the right string to ask what a reader is given — except that the escape is
resolved out of it, `http\://` and `http://` alike, so the two cannot be told
apart there.

Scanning the line instead is not the answer, and #407 tried it: a URL scanner
stops at a backslash written into an authority, which no authority can hold, and
hands back the piece before it as a URL of its own — `http://ex` out of
`http://ex\_ample.com/`, which is a URL to a scanner that asks no more of an
authority than a scheme and a name. That is a false positive of its own, and a
worse one, so #407 kept the literal.

## What GFM does

Neither string is GFM's rule. GFM autolinks out of text with the backslashes
still in it and asks its own questions of what it finds, and it is those that
decide these cases:

| Written | GFM | mado |
| --- | --- | --- |
| `http\://www.example.com/` | not autolinked | reported |
| `http://ex\_ample.com/` | not autolinked — `_` in one of the last two labels | not reported |
| `http://ex\-ample.com/` | autolinked whole | reported |
| `http://example.com/foo\_bar` | autolinked whole | reported |
| `http://localhost/x` | not autolinked — no `.` in the domain | reported |

The last row is the same defect without an escape in it: what mado reports as a
bare URL is what `linkify` accepts, which is not what GFM links.

## Not the same as #406

#406 is the column an inline is reported at, and #407 fixed that by walking the
offsets of the literal along the line. This is which text is a bare URL at all,
and it is not a question about columns.

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Start by searching the codebase for the MD034 rule and its existing tests. Read the current handling around text node literals, comrak's autolink extension, and linkify behavior described in the issue. Done means the examples in the table match GFM: escaped schemes, localhost, and certain escaped domains are not reported, while valid GFM autolinks are handled correctly.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
markdown, rust
Domaine
tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
Active
Clarté
Plutôt claire
Accessibilité débutants
64/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.