Fix #5012: Fc2 image link paste not uploading.

Fix referer spoofing not working for certain fc2.com image URLs.

Spoofing the referer like this redirects to an HTML error page:

* curl -H "Referer: http://wwwew.web.fc2.com" http://wwwew.web.fc2.com/e/405.jpg

Spoofing it like this works:

* curl -H "Referer: http://wwwew.web.fc2.com/e/405.jpg" http://wwwew.web.fc2.com/e/405.jpg
This commit is contained in:
evazion
2022-03-18 04:39:13 -05:00
parent c64df46de4
commit 42144eaa4b
2 changed files with 3 additions and 1 deletions

View File

@@ -6,7 +6,7 @@ module Danbooru
HTTP::Options.register_feature :spoof_referrer, self
def perform(request, &block)
request.headers["Referer"] = request.uri.origin unless request.headers["Referer"].present?
request.headers["Referer"] = request.uri unless request.headers["Referer"].present?
response = yield request
response
end

View File

@@ -356,6 +356,8 @@ class UploadsControllerTest < ActionDispatch::IntegrationTest
should_upload_successfully("https://c.fantia.jp/uploads/post/file/1070093/16faf0b1-58d8-4aac-9e86-b243063eaaf1.jpeg")
should_upload_successfully("https://fantia.jp/posts/1132267")
should_upload_successfully("https://fantia.jp/products/249638")
should_upload_successfully("http://wwwew.web.fc2.com/e/405.jpg")
end
end
end