From 4196ce2600d986ad68bf27b83a40ab3c5da9301e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Tue, 20 Aug 2013 00:33:56 +0200 Subject: [PATCH] Clean links from spoiler and code tags. --- src/General/Config.coffee | 2 +- src/Linkification/Linkify.coffee | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/General/Config.coffee b/src/General/Config.coffee index b35d0a399..24fa40faf 100644 --- a/src/General/Config.coffee +++ b/src/General/Config.coffee @@ -29,7 +29,7 @@ Config = 'Reveal Spoilers': [false, 'Reveal spoiler thumbnails.'] 'Linkification': 'Linkify': [true, 'Convert text links into hyperlinks.'] - 'Clean Links': [true, 'Remove spoiler texts commonly used to bypass banned links.'] + 'Clean Links': [true, 'Remove spoiler and code tags commonly used to bypass blocked links.'] 'Menu': 'Menu': [true, 'Add a drop-down menu to posts.'] 'Report Link': [true, 'Add a report link to the menu.'] diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index ba9125f5a..99f667fbe 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -23,7 +23,7 @@ Linkify = # Replace already-linkified links, # f.e.: https://boards.4chan.org/b/% $.replace parent, anchor - Linkify.cleanLink anchor if Conf['Clean Links'] + Linkify.cleanLink anchor, link if Conf['Clean Links'] walker.currentNode = anchor.lastChild else walker.currentNode = boundaries.endNode @@ -97,5 +97,8 @@ Linkify = boundaries.endNode = parent boundaries.endOffset = [parent.childNodes...].indexOf(parentNode) + 1 - cleanLink: (anchor) -> - # TODO + cleanLink: (anchor, link) -> + {length} = link + for node in $$ 's, .prettyprint', anchor + $.replace node, [node.childNodes...] if length > node.textContent.length + return