Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check for email addresses in verbatim code #471

Closed
norswap opened this issue Jan 19, 2022 · 5 comments
Closed

Don't check for email addresses in verbatim code #471

norswap opened this issue Jan 19, 2022 · 5 comments

Comments

@norswap
Copy link

norswap commented Jan 19, 2022

Small thing, but with this input:

    go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0

(So this instruction in a markdown code code block.)

you get lychee output:

✗ github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 (Unreachable mail address: github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0)

Which is obviously not the desired outcome. Verbatim blocks should probably be ignored.

@lebensterben
Copy link
Member

lebensterben commented Jan 19, 2022

This is a bug obviously...

the domain part of an email address (those characters after '@'), can be any alphanumerical character or an '-'. With exception that:

  • '-' cannot be the first or last character
  • top level domain cannot be all numerical characters.

"0" is all numerical, so it cannot be a top level domain, and thus it cannot be an email address.

@mre
Copy link
Member

mre commented Jan 19, 2022

@norswap thanks for the bug report. This is an issue in linkify. robinst/linkify#29
@lebensterben good input. Is there a spec where these rules are defined? Can you mention it in the linkify issue above?

@mre
Copy link
Member

mre commented Jan 19, 2022

In general I think the verbatim part is fine but the e-mail address detection needs to be improved. This line would not show up if the false-positive was filtered out correctly.

@mre
Copy link
Member

mre commented Feb 23, 2022

Excluding code blocks will be tackled in #523.

@mre
Copy link
Member

mre commented Apr 6, 2022

This gets ignored in the latest master now. 🎉
If I have an input file like this called test.md:

Some content.
```
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0
```
Other test content

and I call lychee, the code block will be ignored by default:

❯❯❯ lychee test.md
🔍 0 Total ✅ 0 OK 🚫 0 Errors

The old behavior can be restored with --include-verbatim:

❯❯❯ lychee --include-verbatim test.md
Issues found in 1 input. Find details below.

[test.md]:
✗ [ERR] github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0 | Unreachable mail address: github.com/golangci/golangci-lint/cmd/golangci-lint@v1.43.0: Invalid: Email doesn't exist or is syntactically incorrect

🔍 1 Total ✅ 0 OK 🚫 1 Error (HTTP:1)

@mre mre closed this as completed Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants