From 49122baa4ab8081bd7ebe7d5cf6fa92f374ddacd Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 13 Jul 2014 13:03:29 -0700 Subject: [PATCH] don't remove encryption without asking --- src/Archive/Redirect.coffee | 14 +++++++++++++- src/General/Main.coffee | 4 ++-- src/Images/Gallery.coffee | 1 + src/Images/ImageExpand.coffee | 2 +- src/Images/ImageHover.coffee | 2 +- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/Archive/Redirect.coffee b/src/Archive/Redirect.coffee index 4db6965ba..03c283ad2 100755 --- a/src/Archive/Redirect.coffee +++ b/src/Archive/Redirect.coffee @@ -53,7 +53,9 @@ Redirect = post: (archive, {boardID, postID}) -> # For fuuka-based archives: # https://github.com/eksopl/fuuka/issues/27 - URL = new String "#{Redirect.protocol archive}#{archive.domain}/_/api/chan/post/?board=#{boardID}&num=#{postID}" + protocol = Redirect.protocol archive + return '' unless protocol is 'https://' or location.protocol is 'http:' + URL = new String "#{protocol}#{archive.domain}/_/api/chan/post/?board=#{boardID}&num=#{postID}" URL.archive = archive URL @@ -73,3 +75,13 @@ Redirect = else "#{boardID}/?task=search2&search_#{if type is 'image' then 'media_hash' else type}=#{value}" "#{Redirect.protocol archive}#{archive.domain}/#{path}" + + navigate: (URL, alternative) -> + if ( + /^https:\/\//.test(URL) or + location.protocol is 'http:' or + confirm "Redirect to #{URL}?\n\nYour connection will not be encrypted." + ) + location.replace URL + else if alternative + location.replace alternative diff --git a/src/General/Main.coffee b/src/General/Main.coffee index 3cddd156a..842d7114f 100755 --- a/src/General/Main.coffee +++ b/src/General/Main.coffee @@ -54,7 +54,7 @@ Main = URL = Redirect.to 'file', boardID: g.BOARD.ID filename: pathname[pathname.length - 1] - location.replace URL if URL + Redirect.navigate URL else if Conf['Loop in New Tab'] and video = $ 'video' Video.configure video $.on video, 'click', -> @@ -121,7 +121,7 @@ Main = boardID: g.BOARD.ID threadID: g.THREADID postID: +location.hash.match /\d+/ # post number or 0 - location.replace href or "/#{g.BOARD}/" + Redirect.navigate href, "/#{g.BOARD}/" return # Something might have gone wrong! diff --git a/src/Images/Gallery.coffee b/src/Images/Gallery.coffee index 0d5a7512f..9f7cef9a0 100644 --- a/src/Images/Gallery.coffee +++ b/src/Images/Gallery.coffee @@ -180,6 +180,7 @@ Gallery = filename: src[src.length - 1] if URL thumb.href = URL + if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:') return unless Gallery.nodes.current is file file.src = URL return diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 8a6a6530a..a448ecdb8 100755 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -207,7 +207,7 @@ ImageExpand = URL = Redirect.to 'file', boardID: src[3] filename: src[src.length - 1] - if URL + if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:') setTimeout ImageExpand.expand, 10000, post, URL return if g.DEAD or post.isDead or post.file.isDead diff --git a/src/Images/ImageHover.coffee b/src/Images/ImageHover.coffee index 378de4e71..c0ff4beb6 100755 --- a/src/Images/ImageHover.coffee +++ b/src/Images/ImageHover.coffee @@ -53,7 +53,7 @@ ImageHover = URL = Redirect.to 'file', boardID: src[3] filename: src[src.length - 1].replace /\?.+$/, '' - if URL + if URL and (/^https:\/\//.test(URL) or location.protocol is 'http:') @src = URL return if g.DEAD or post.isDead or post.file.isDead