mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2025-01-26 07:05:13 +00:00
Add some rel attributes to links inside markdown (#461)
I currently don't differentiate between "trusted" markdown and untrusted, but this should be good enough. Basically tells the browser not to send a referrer, and (not sure if relevant here) not to expose a window opener object. Also tells search engines that the link is not endorsed with "nofollow".
This commit is contained in:
parent
dd4510f371
commit
e9b1f6a6c4
|
@ -212,6 +212,13 @@ markdown.renderer.rules.table_open = function (tokens, idx) {
|
||||||
// Format tables nicer (bootstrap). Force auto-width (default is 100%)
|
// Format tables nicer (bootstrap). Force auto-width (default is 100%)
|
||||||
return '<table class="table table-striped table-bordered" style="width: auto;">';
|
return '<table class="table table-striped table-bordered" style="width: auto;">';
|
||||||
}
|
}
|
||||||
|
var defaultRender = markdown.renderer.rules.link_open || function(tokens, idx, options, env, self) {
|
||||||
|
return self.renderToken(tokens, idx, options);
|
||||||
|
};
|
||||||
|
markdown.renderer.rules.link_open = function (tokens, idx, options, env, self) {
|
||||||
|
tokens[idx].attrPush(['rel', 'noopener nofollow noreferrer']);
|
||||||
|
return defaultRender(tokens, idx, options, env, self);
|
||||||
|
}
|
||||||
|
|
||||||
// Initialise markdown editors on page
|
// Initialise markdown editors on page
|
||||||
document.addEventListener("DOMContentLoaded", function() {
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
|
Loading…
Reference in a new issue