From 6387eb4ad15c72f677b42b3cb05ea02843be9b6c Mon Sep 17 00:00:00 2001 From: ccd0 Date: Wed, 10 Jul 2019 18:10:42 -0700 Subject: [PATCH] Fix image error handling on Tinyboard/vichan sites; don't try to redirect to 4chan archives. --- src/Images/ImageCommon.coffee | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Images/ImageCommon.coffee b/src/Images/ImageCommon.coffee index 2a42d4b8c..eed544558 100644 --- a/src/Images/ImageCommon.coffee +++ b/src/Images/ImageCommon.coffee @@ -34,27 +34,30 @@ ImageCommon = return true isFromArchive: (file) -> - !ImageHost.test(file.src.split('/')[2]) + g.SITE.software is 'yotsuba' and !ImageHost.test(file.src.split('/')[2]) error: (file, post, delay, cb) -> src = post.file.url.split '/' - URL = Redirect.to 'file', { - boardID: post.board.ID - filename: src[src.length - 1] - } - unless Conf['404 Redirect'] and URL and Redirect.securityCheck URL - URL = null + url = null + if g.SITE.software is 'yotsuba' and Conf['404 Redirect'] + url = Redirect.to 'file', { + boardID: post.board.ID + filename: src[src.length - 1] + } + url = null unless url and Redirect.securityCheck(url) - return cb URL if (post.isDead or post.file.isDead) and not ImageCommon.isFromArchive file + return cb url if (post.isDead or post.file.isDead) and not ImageCommon.isFromArchive(file) - timeoutID = setTimeout (-> cb URL), delay if delay? + timeoutID = setTimeout (-> cb url), delay if delay? return if post.isDead or post.file.isDead redirect = -> unless ImageCommon.isFromArchive file clearTimeout timeoutID if delay? - cb URL + cb url - $.ajax g.SITE.urls.threadJSON({boardID: post.boardID, threadID: post.threadID}), onloadend: -> + threadJSON = g.SITE.urls.threadJSON?(post) + return unless threadJSON + $.ajax threadJSON, onloadend: -> post.kill !post.isClone if @status is 404 return redirect() if @status isnt 200 for postObj in @response.posts @@ -66,7 +69,7 @@ ImageCommon = post.kill true redirect() else - URL = post.file.url + url = post.file.url # Add controls, but not until the mouse is moved over the video. addControls: (video) ->