Skip to content
Permalink
Browse files

Respect DNT header

Do Not Track (DNT) is an old web standard in order to notify pages that
the user doesn't want to be tracked. Even while a lot of pages either
ignore this header or even worse, use it for tracking purposes, the
orignal intention of this header is good and should be adopted.

This patch implements a respect of the DNT header by no longer including
the optional Google Analytics and disqus integrations when sending a DNT
header. This should reduce outside resource usage and help to stay more
private.

This should later-on extended towards other document content (i.e.
iframe based content).

The reason to not change the CDN handling is that CDNs will be
deprecated with next release and removed in long term.

Signed-off-by: Sheogorath <sheogorath@shivering-isles.com>
  • Loading branch information...
SISheogorath committed Jun 8, 2019
1 parent 6462968 commit da4665c7590616dd3d17baf4488006dac98eeee4
Showing with 7 additions and 5 deletions.
  1. +4 −2 lib/response.js
  2. +1 −1 public/views/pretty.ejs
  3. +1 −1 public/views/shared/ga.ejs
  4. +1 −1 public/views/slide.ejs
@@ -226,7 +226,8 @@ function showPublishNote (req, res, next) {
robots: meta.robots || false, // default allow robots
GA: meta.GA,
disqus: meta.disqus,
cspNonce: res.locals.nonce
cspNonce: res.locals.nonce,
dnt: req.headers.dnt
}
return renderPublish(data, res)
}).catch(function (err) {
@@ -608,7 +609,8 @@ function showPublishSlide (req, res, next) {
robots: meta.robots || false, // default allow robots
GA: meta.GA,
disqus: meta.disqus,
cspNonce: res.locals.nonce
cspNonce: res.locals.nonce,
dnt: req.headers.dnt
}
return renderPublishSlide(data, res)
}).catch(function (err) {
@@ -63,7 +63,7 @@
</div>
</div>
<div id="ui-toc-affix" class="ui-affix-toc ui-toc-dropdown unselectable hidden-print" data-spy="affix" style="display:none;"></div>
<% if(typeof disqus !== 'undefined' && disqus) { %>
<% if(typeof disqus !== 'undefined' && disqus && !dnt) { %>
<div class="container-fluid" style="max-width: 758px; margin-bottom: 40px;">
<%- include shared/disqus %>
</div>
@@ -1,4 +1,4 @@
<% if(typeof GA !== 'undefined' && GA) { %>
<% if(typeof GA !== 'undefined' && GA && !dnt) { %>
<script nonce="<%= cspNonce %>">
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
@@ -78,7 +78,7 @@
<% } %>
</small>
</div>
<% if(typeof disqus !== 'undefined' && disqus) { %>
<% if(typeof disqus !== 'undefined' && disqus && !dnt) { %>
<div class="slides-disqus">
<%- include shared/disqus %>
</div>

0 comments on commit da4665c

Please sign in to comment.
You can’t perform that action at this time.