posts: fix exception when viewing post with source Blog..

Fix a PublicSuffix::DomainNotAllowed exception raised with viewing or editing a post
with a source like `Blog.`.

This happened when parsing the post's source. `Danbooru::URL.parse("Blog.")` would
heuristically parse the source into `http://blog`. Calling any methods related to the
URL's hostname or domain would lead to calling `PublicSuffix.parse("blog")`, which
would fail with PublicSuffix::DomainNotAllowed.
This commit is contained in:
evazion
2022-03-21 03:12:17 -05:00
parent defea08084
commit 56f47c60e1
4 changed files with 28 additions and 3 deletions

View File

@@ -646,6 +646,15 @@ class PostsControllerTest < ActionDispatch::IntegrationTest
end
end
context "with a non-web source" do
should "render" do
@post.update!(source: "Blog.")
get post_path(@post)
assert_response :success
end
end
should "respect the disable tagged filenames option in the Download link" do
@user.update!(disable_tagged_filenames: true)
get_auth post_path(@post), @user