From 854d587373f1de00610652d2dd05e673e0b9ff61 Mon Sep 17 00:00:00 2001 From: Toks Date: Wed, 3 Jun 2015 20:59:24 -0400 Subject: [PATCH] Fix upload source fetcher fetching from wrong work page for all sites e.g. If you were on an html work page on pixiv, clicked a link to a different html work page on pixiv, and then clicked the bookmarklet, then it used to fetch the source from the FIRST work you were on instead of the second. --- app/logical/sources/strategies/base.rb | 2 +- app/logical/sources/strategies/deviant_art.rb | 2 +- app/logical/sources/strategies/nico_seiga.rb | 2 +- app/logical/sources/strategies/nijie.rb | 2 +- app/logical/sources/strategies/pixiv.rb | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/logical/sources/strategies/base.rb b/app/logical/sources/strategies/base.rb index bba04fb2c..1d357f5ee 100644 --- a/app/logical/sources/strategies/base.rb +++ b/app/logical/sources/strategies/base.rb @@ -70,7 +70,7 @@ module Sources end def referer_url(template) - template.params[:ref] || template.params[:url] + raise NotImplementedError end def image_urls diff --git a/app/logical/sources/strategies/deviant_art.rb b/app/logical/sources/strategies/deviant_art.rb index 63f9290a6..19306ea5b 100644 --- a/app/logical/sources/strategies/deviant_art.rb +++ b/app/logical/sources/strategies/deviant_art.rb @@ -6,7 +6,7 @@ module Sources end def referer_url(template) - if template.params[:ref] =~ /deviantart\.com\/art\// + if template.params[:ref] =~ /deviantart\.com\/art\// && template.params[:url] =~ /https?:\/\/(?:fc|th|pre|orig|img)\d{2}\.deviantart\.net\// template.params[:ref] else template.params[:url] diff --git a/app/logical/sources/strategies/nico_seiga.rb b/app/logical/sources/strategies/nico_seiga.rb index be83a9a4d..2ef00f579 100644 --- a/app/logical/sources/strategies/nico_seiga.rb +++ b/app/logical/sources/strategies/nico_seiga.rb @@ -6,7 +6,7 @@ module Sources end def referer_url(template) - if template.params[:ref] =~ /seiga\.nicovideo\.jp\/seiga\/im\d+/ + if template.params[:ref] =~ /seiga\.nicovideo\.jp\/seiga\/im\d+/ && template.params[:url] =~ /http:\/\/lohas\.nicoseiga\.jp\/priv\// template.params[:ref] else template.params[:url] diff --git a/app/logical/sources/strategies/nijie.rb b/app/logical/sources/strategies/nijie.rb index 79cdbe1b9..1f5e7702e 100644 --- a/app/logical/sources/strategies/nijie.rb +++ b/app/logical/sources/strategies/nijie.rb @@ -6,7 +6,7 @@ module Sources end def referer_url(template) - if template.params[:ref] =~ /nijie\.info\/view\.php/ && template.params[:ref] =~ /id=\d+/ + if template.params[:ref] =~ /nijie\.info\/view\.php.+id=\d+/ && template.params[:url] =~ /pic\d+\.nijie.info\/nijie_picture\// template.params[:ref] else template.params[:url] diff --git a/app/logical/sources/strategies/pixiv.rb b/app/logical/sources/strategies/pixiv.rb index d4e7044ad..3c333eb23 100644 --- a/app/logical/sources/strategies/pixiv.rb +++ b/app/logical/sources/strategies/pixiv.rb @@ -20,7 +20,7 @@ module Sources end def referer_url(template) - if template.params[:ref] =~ /pixiv\.net\/member_illust/ && template.params[:ref] =~ /mode=medium/ + if template.params[:ref] =~ /pixiv\.net\/member_illust.+mode=medium/ && template.params[:url] =~ /#{IMG}|#{I12}/ template.params[:ref] else template.params[:url]