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

Detect relative urls in tidy check #43632

Merged
merged 2 commits into from
Aug 11, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/tools/tidy/src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ fn line_is_url(line: &str) -> bool {
=> state = EXP_URL,

(EXP_LINK_LABEL_OR_URL, w)
if w.starts_with("http://") || w.starts_with("https://")
if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so this change will permit long lines anywhere that there is a word beginning with ../. I'm not sure if this is what we want. Maybe it is, or maybe it's too accepting.

On the other hand, if we only keep the second change, below, then the [deref-coercions]: link in the relevant PR would put us into the EXP_URL state, and there we can accept ../, where the context is a bit less ambiguous.

I could go either way, just saying that maybe we don't want this line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is currently one line in the codebase which would be affected:

$ git grep -E '\s?//(/|!)?\s\.\./'
src/libstd/net/tcp.rs:    /// ../../std/net/trait.ToSocketAddrs.html#tymethod.to_socket_addrs

It is part of a Markdown link.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favour of removing (though I think it's just the first word on a line, rather than any).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

=> state = EXP_END,

(EXP_URL, w)
if w.starts_with("http://") || w.starts_with("https://")
if w.starts_with("http://") || w.starts_with("https://") || w.starts_with("../")
=> state = EXP_END,

(_, _) => return false,
Expand Down