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

HTMLWriter: allow extra attributes for external asset links, default to no-referrer policy #2401

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

exaexa
Copy link

@exaexa exaexa commented Jan 15, 2024

Should close #2391. cc @mortenpi

( I don't expect this code to stay for very long, but it's a simple fix that may hold for at least as long as the #2159 isn't fixed. )

@exaexa exaexa changed the title HTMLWriter: allow extra attributes for external links, default to no-referrer policy HTMLWriter: allow extra attributes for external asset links, default to no-referrer policy Jan 15, 2024
Copy link
Member

@mortenpi mortenpi left a comment

Choose a reason for hiding this comment

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

Something I noticed: we load most of our JS dependencies via requirejs, and so those are not covered by these changes. So the CDN will still know what site is making the requests. I wonder if using the <meta name="referer"> tag would be the more appropriate solution?


HTMLContext(doc, settings=nothing) = new(
doc, settings, [], "", "", "", [], "",
Documenter.NavNode("search", "Search", nothing),
AtExampleFallbackWarning[],
[:referrerpolicy => "no-referrer"]
Copy link
Member

Choose a reason for hiding this comment

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

Just thinking out loud, but I wonder if it should/could be strict-origin. But I'm also not sure it would really make a difference.

@@ -619,11 +619,13 @@ mutable struct HTMLContext
search_index_js :: String
search_navnode :: Documenter.NavNode
atexample_warnings::Vector{AtExampleFallbackWarning}
external_link_attribs :: Vector{Pair{Symbol,String}}
Copy link
Member

Choose a reason for hiding this comment

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

Not very important, but in principle, the fields of this struct are meant for mutable state. I think I'd make this a global const for now.

And just a small nitpick:

Suggested change
external_link_attribs :: Vector{Pair{Symbol,String}}
external_link_attributes :: Vector{Pair{Symbol,String}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent leaking trackable pageview stats to CDNs by default
2 participants