Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6529 Prevent work imports from AO3 #4981

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/story_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions config/locales/models/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 9 additions & 0 deletions features/importing/work_import_errors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Loading