From e448e489e21c541fae8cf3bb37ca5b6ecb304fc5 Mon Sep 17 00:00:00 2001 From: ghostrigger Date: Sun, 22 Jun 2014 23:18:51 +0800 Subject: [PATCH] #1866: support e-hentai source redirection * hopefully prevents error pages when the url during upload expires * makes use of file sha-1 hash and filename in the url to query the e-hentai search page * the file hash by itself is enough to generate a result but the filename is also added for completeness (the page displays the filename being searched) * ip addresses, port numbers, and unix timestamps validation can also be added later * a better solution maybe is to get the gallery ids and gallery tokens directly --- app/models/post.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/post.rb b/app/models/post.rb index d649e3194..915794fe1 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -331,6 +331,11 @@ class Post < ActiveRecord::Base subdomain = $1 filename = $2 "http://#{subdomain}.wikia.com/wiki/File:#{filename}" + + when %r{\Ahttp://(?:(?:\d{1,3}\.){1,3}\d{1,3}):(?:\d{1,5})/h/([a-f0-9]{40})-(?:\d+-){3}(?:png|gif|(?:jpe?g?))/keystamp=\d+-[a-f0-9]{10}/([^/]+)}i + sha1hash = $1 + filename = $2 + "http://g.e-hentai.org/?f_shash=#{sha1hash}&fs_from=#{filename}" else source