diff --git a/app/models/story_parser.rb b/app/models/story_parser.rb index 9647707480..2c2e9e69d9 100644 --- a/app/models/story_parser.rb +++ b/app/models/story_parser.rb @@ -799,6 +799,8 @@ def download_with_timeout(location, limit = 10) # we do a little cleanup here in case the user hasn't included the 'http://' # or if they've used capital letters or an underscore in the hostname uri = UrlFormatter.new(location).standardized + raise Error, I18n.t("story_parser.on_archive") if ArchiveConfig.PERMITTED_HOSTS.include?(uri.host) + response = Net::HTTP.get_response(uri) case response when Net::HTTPSuccess diff --git a/config/config.yml b/config/config.yml index 149a685928..9e1b280890 100644 --- a/config/config.yml +++ b/config/config.yml @@ -675,7 +675,8 @@ HIT_COUNT_ROLLOVER_HOUR: 3 # The batch size for calculating a work's filters from its tags: FILTER_UPDATE_BATCH_SIZE: 100 -# URLs for which we should not display the proxy notice. Alphabetical by +# URLs for which we should not display the proxy notice. URLs from these hosts +# are allowed in Abuse reports and disallowed in Work imports. Alphabetical by # environment. PERMITTED_HOSTS: [ # Production diff --git a/config/locales/models/en.yml b/config/locales/models/en.yml index 1c9c25b5f2..cffa9d02aa 100644 --- a/config/locales/models/en.yml +++ b/config/locales/models/en.yml @@ -257,5 +257,7 @@ en: closed_ticket: must not be closed. invalid_department: must be in your department. required: must exist and not be spam. + story_parser: + on_archive: URL is for a work on the Archive. Please bookmark it directly instead. subscriptions: deleted: Deleted item diff --git a/features/importing/work_import_errors.feature b/features/importing/work_import_errors.feature index c8e6712057..cc084d33b5 100644 --- a/features/importing/work_import_errors.feature +++ b/features/importing/work_import_errors.feature @@ -15,3 +15,12 @@ Feature: Import Works Then I should see "We couldn't successfully import that work, sorry: We couldn't download anything from http://no-content. Please make sure that the URL is correct and complete, and try again." When I go to my works page Then I should see "Drafts (0)" + + Scenario: Cannot import works from the current archive + Given I set up importing + And I fill in "urls" with "https://archiveofourown.org/works/54711364" + And I select "English" from "Choose a language" + And I press "Import" + Then I should see "We couldn't successfully import that work, sorry: URL is for a work on the Archive. Please bookmark it directly instead." + When I go to my works page + Then I should see "Drafts (0)"