From b12b6375686152a2534861bbb8cb01922d2e546a Mon Sep 17 00:00:00 2001 From: Toks Date: Sun, 4 Oct 2015 16:57:40 -0400 Subject: [PATCH] Strip source whitespace before upload This was already done for post edits but not on upload. --- app/models/upload.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/models/upload.rb b/app/models/upload.rb index a743a5db5..cf5be2e70 100644 --- a/app/models/upload.rb +++ b/app/models/upload.rb @@ -102,6 +102,7 @@ class Upload < ActiveRecord::Base def process_once CurrentUser.scoped(uploader, uploader_ip_addr) do update_attribute(:status, "processing") + self.source = strip_source if is_downloadable? self.source = download_from_source(temp_file_path) end @@ -379,6 +380,10 @@ class Upload < ActiveRecord::Base end module DownloaderMethods + def strip_source + source.try(:strip) + end + # Determines whether the source is downloadable def is_downloadable? source =~ /^https?:\/\// && file_path.blank?