Commit Graph

11629 Commits

Author SHA1 Message Date
evazion
c64df46de4 artists: make artist finder use url instead of normalized_url.
Make the artist finder search for artists using the `url` field instead
of the `normalized_url` field. This lets us get rid of `normalized_url`
in the future.

As described in 10dac3ee5, artist URLs have both a `url` column and a
`normalized_url` column. The `normalized_url` column was the one used
for artist finding. The `url` was secretly normalized behind the scenes
so that artist finding would work no matter how the URL was written in
the artist entry. This is no longer necessary now that URLs are directly
normalized in artist entries.

This fixes various cases where artist finding didn't work for non-obvious
reasons, usually because the URL wasn't written in the right format so
it wasn't properly normalized behind the scenes.

This also makes it so that artist finding is case-insensitive, which
fixes #4821. Hopefully no sites are perverse enough to allow two
different usernames that differ only in case.

Users running their own Danbooru instance may have to fix the URLs in
their artist entries for artist finding to work again. There are a few
fix scripts to help with this:

* script/fixes/104_normalize_weibo_artist_urls.rb
* script/fixes/105_normalize_pixiv_artist_urls.rb
* script/fixes/106_normalize_artist_urls.rb
2022-03-18 04:00:16 -05:00
evazion
10dac3ee51 artists: normalize urls added to artist entries.
When a URL is added to an artist entry, normalize it to a standard form.

Artist URLs have both a `url` column and a `normalized_url` column. The
`normalized_url` is used for artist finding and the `url` is the raw URL
entered by the user. Previously only the `normalized_url` field was
normalized; now the URL entered by the user is also converted to a
normalized form.

This means that if an URL like this is added to an artist entry:

* http://www.pixiv.net/member.php?id=1234
* http://www.pixiv.net/en/users/1234
* http://www.twitter.com/DanbooruBot/
* http://mobile.twitter.com/DanbooruBot/

It will get normalized to this:

* https://www.pixiv.net/users/1234
* https://twitter.com/DanbooruBot

This fixes problems with duplicate URLs being added to artist entries
because URLs weren't normalized to a single form.
2022-03-18 02:06:50 -05:00
evazion
455ee9a52a fc2: parse more url types. 2022-03-18 02:06:30 -05:00
evazion
03d2a86ef1 artists: normalize fc2.com profile urls. 2022-03-17 19:42:57 -05:00
evazion
04c03fa4e6 artist: normalize more artist url formats. 2022-03-16 17:17:50 -05:00
NamelessContributor
c669b16c32 url icons: replace some icons with better versions
mangaupdates, nijie, sakura-ne-jp: replaced with higher resolution,
  the old icons look blurry on hidpi screens.
skeb, tumblr: replaced with transparent versions.
2022-03-15 16:12:08 +01:00
NamelessContributor
c3a5ce9019 simple_form: Don't hide hints on mobile. Fix #4997
Hints are displayed below their fields on small screens.
2022-03-15 14:39:37 +01:00
NamelessContributor
1a4d9dc7da editorconfig: add scss 2022-03-15 14:06:16 +01:00
evazion
ded03df1ff tests: fix more broken tests. 2022-03-15 05:14:56 -05:00
evazion
644dfaf74c tests: fix broken tests. 2022-03-15 04:45:30 -05:00
evazion
133c45ee29 sources: parse more profile url formats.
Add support for parsing these URL formats:

* https://www.artstation.com/felipecartin/profile
* https://www.deviantart.com/nlpsllp/gallery
* https://fantia.jp/asanagi
* https://www.lofter.com/front/blog/home-page/noshiqian
* https://www.lofter.com/app/xiaokonggedmx
* https://www.lofter.com/blog/semblance
* https://q.nicovideo.jp/users/18700356
* https://dic.nicovideo.jp/u/11141663
* https://3d.nicovideo.jp/users/109584
* https://3d.nicovideo.jp/u/siobi
* https://game.nicovideo.jp/atsumaru/users/7757217
* https://www.pixiv.net/user/13569921/series/81967
* https://pixiv.cc/zerousagi/
* https://www.plurk.com/u/ddks2923
* https://www.plurk.com/m/u/leiy1225
* https://www.plurk.com/s/u/salmonroe13
* https://www.plurk.com/RSSSww/invite/4
* https://skeb.jp/@okku_oxn/works
* https://www.tumblr.com/blog/view/artofelaineho/187614935612
* https://www.tumblr.com/blog/view/artofelaineho
* https://www.tumblr.com/blog/artofelaineho
* https://www.tumblr.com/dashboard/blog/dankwartart
* https://rosarrie.tumblr.com/archive
* https://whereisnovember.tumblr.com/tagged/art
* https://twitpic.com/photos/Type10TK
* https://www.weibo.com/detail/4676597657371957
* https://www.weibo.com/u/5957640693/home?wvr=5
* https://www.weibo.com/lvxiuzi0/home
2022-03-15 00:49:54 -05:00
evazion
04226d3409 pixiv: normalize pixiv urls in artist entries.
Normalize Pixiv URLs to `https://www.pixiv.net/users/1234` format.
2022-03-14 16:43:19 -05:00
evazion
223742c365 weibo: normalize weibo urls in artist entries.
Normalize all Weibo URLs in artist entries to one of these forms:

* https://www.weibo.com/u/5399876326
* https://www.weibo.com/p/1005055399876326
* https://www.weibo.com/chengziyou666
2022-03-13 21:16:56 -05:00
evazion
1d9a15a119 weibo: handle a couple more profile url types.
Parse these profile URL types:

* https://www.weibo.cn/endlessnsmt
* https://www.weibo.com/p/1005055399876326

Also add anchors around the regexes so they have to match the full string.
2022-03-13 20:32:57 -05:00
evazion
be9ef0c49f artists: add m.weibo.cn urls to artist finder blacklist. 2022-03-13 03:54:17 -05:00
evazion
cf8b8207e2 artists: change how artist urls are normalized.
Change how artist URLs are normalized in artist entries. Don't try to secretly
convert image URLs to profile URLs in artist entries. For example, if someone puts a
Pixiv image URL in an artist entry, don't secretly try to fetch the source and
convert it into a profile URL in the `normalized_url` field.

We did this because years ago, it was standard practice to put image URLs in artist
entries. Pixiv image URLs used to contain the artist's username, so we used to put
image URLs in artist entries for artist finding purposes. But Pixiv changed it so
that image URLs no longer contained the username, so we dealt with it by adding a
`normalized_url` column to artist_urls and secretly converting image URLs to profile
URLs in this field. But this is no longer necessary because now we don't normally put
image URLs in artist entries in the first place.

Now the `profile_url` method in `Source::URL` is used to normalize URLs in artist
entries. This lets us parse various profile URL formats and normalize them into a
single canonical form.

This also removes the `normalize_for_artist_finder` method from source strategies.
Instead the `profile_url` method is used for artist finding purposes. So the profile
URL returned by the source strategy needs to be the same as the URL in the artist
entry in order for artist finding to work.
2022-03-13 03:54:17 -05:00
evazion
9343f7c912 Source::URL: add profile_url method.
Add a method for converting a source URL into a profile URL. This will
be used for normalizing profile URLs in artist entries.

Also add the ability to parse a few more profile URL formats.
2022-03-13 03:54:17 -05:00
evazion
787b5c8e27 sources: merge Sta.sh strategy into DeviantArt strategy.
This turns out to be a little simpler than keeping them separate. The
only thing special we have to do for Sta.sh is use the Sta.sh page when
we have a DeviantArt image with a Sta.sh referer.
2022-03-12 00:57:43 -06:00
evazion
f2028c14fb Fix #5045: Exception on uploads when SauceNAO is the referrer URL.
Bug: We assumed the referer URL was from the same site as the target
URL. We tried to call methods on the referer only supported by the
target URL.

Fix: Ignore the referer URL when it's from a different site than the
target URL.
2022-03-12 00:04:39 -06:00
evazion
28971fe103 sources: factor out site_name method. 2022-03-11 23:20:53 -06:00
evazion
b4aea72d04 sources: remove preview_urls method from base strategy.
Remove the `preview_urls` method from strategies. The only place this was used was
when doing IQDB searches, to download the thumbnail image from the source instead of
the full image.

This wasn't worth it for a few reasons:

* Thumbnails on other sites are sometimes not the size we want, which could affect
  IQDB results.
* Grabbing thumbnails is complex for some sites. You can't always just rewrite the
  image URL. Sometimes it requires extra API calls, which can be slower than just
  grabbing the full image.
* For videos and animations, thumbnails from other sites don't always match our
  thumbnails. We do smart thumbnail generation to try to avoid blank thumbnails, which
  means we don't always pick the first frame, which could affect IQDB results.

API changes:

* /iqdb_queries?search[file_url] now downloads the URL as is without any modification.
  Before it tried to change thumbnail and sample size image URLs to the full version.

* /iqdb_queries?search[url] now returns an error if the URL is for a HTML page that
  contains multiple images. Before it would grab only the first image and silently
  ignore the rest.
2022-03-11 03:22:23 -06:00
evazion
2f61486ac6 sources: remove image_url method from base strategy.
Remove the `image_url` method from source strategies. This method would
return only the first image if a source had multiple images. The
`image_urls` method should be used instead. Tests were the main place
that still used `image_url` instead of `image_urls`.

Also make post replacements return an error if replacing with a source
that contains multiple images, instead of just blindly replacing the
post with the first image in the source.
2022-03-11 01:59:21 -06:00
evazion
4701027f45 sources: remove unused methods from base strategy.
Remove unused `urls`, `parsed_urls`, and `domains` methods.
2022-03-10 23:11:00 -06:00
evazion
2460ac0927 Merge pull request #5044 from nonamethanks/modqueue-thumb-size
Modqueue: support variable size thumbnails
2022-03-10 15:32:20 -06:00
evazion
5016d9ad26 Merge pull request #5043 from nonamethanks/fantia-support
Add Fantia support
2022-03-10 15:21:03 -06:00
evazion
8bba1b0a54 weibo: add test for m.weibo.cn/detail urls. 2022-03-10 15:04:02 -06:00
evazion
29fc072cf1 Merge pull request #5042 from nonamethanks/weibo-fix-typo
weibo: fix typo in strategy
2022-03-10 15:01:12 -06:00
evazion
0252b3608c Merge pull request #5041 from NamelessContributor/fix-mode-menu
post_mode_menu: update preview link selector
2022-03-10 14:58:21 -06:00
nonamethanks
5b5f61c2ea Modqueue: support variable size thumbnails 2022-03-10 20:39:45 +01:00
nonamethanks
a6549bc6fe Add Fantia support
Also fixes a regression in 74fdeef10c
that stopped mastodon urls from being given the right priority.
2022-03-10 17:43:32 +01:00
evazion
43a665a66d sources: factor out Source::URL::NicoSeiga. 2022-03-10 04:53:51 -06:00
nonamethanks
93adba06e5 weibo: fix typo in strategy 2022-03-10 08:31:23 +01:00
evazion
34854185be sources: factor out Source::URL::DeviantArt and Source::URL::Stash. 2022-03-10 00:29:49 -06:00
NamelessContributor
3b63174525 post_mode_menu: update preview link selector
Fixes the post-score link triggering the mode menu action as well as
all three score links getting the blue border on hover.
2022-03-09 10:01:09 +01:00
evazion
28f962ccfb artists: fix Pawoo icon not showing up in artist urls. 2022-03-09 02:27:07 -06:00
evazion
9f16602930 artists: fix Fanbox icon not showing up for Fanbox urls. 2022-03-09 02:08:14 -06:00
evazion
dcbc9b3140 js: fix Alpine Warning: Unable to initialize.
Fix this Javascript warniing:

    Alpine Warning: Unable to initialize. Trying to load Alpine before
    `<body>` is available. Did you forget to add `defer` in Alpine's
    `<script>` tag?
2022-03-09 01:35:02 -06:00
evazion
80939f5e22 users: fix name changes not being validated.
Fix names not being validated when a user changes their name. Regression in 5ce724f1e.
2022-03-09 01:14:09 -06:00
evazion
d770f0bb95 tests: fix broken tests. 2022-03-09 01:14:09 -06:00
evazion
bb4b8619f5 pixiv: fix Source::URL::Pixiv not being included in Source::URL list. 2022-03-09 01:14:09 -06:00
evazion
8a50148823 pixiv: fixup bug with fetching image_urls for bad_id posts.
Fix `image_urls` returning `[nil]` when fetching data for a image URL
that was bad_id. In that case `original_urls` is empty, so we fall back
to using the deleted image URL as-is.
2022-03-09 01:14:09 -06:00
evazion
c989726313 rails: enable remove_deprecated_time_with_zone_name.
Fix this deprecation warning:

    DEPRECATION WARNING: ActiveSupport::TimeWithZone.name has been deprecated
    and from Rails 7.1 will use the default Ruby implementation. You can set
    `config.active_support.remove_deprecated_time_with_zone_name = true` to
    enable the new behavior now.

Triggered by the XML serializer in the API.
2022-03-09 01:14:09 -06:00
evazion
ec190a2d10 Update Rails to 7.0.2.3.
Fixes CVE-2022-21831 (this does not affect Danbooru).

* https://discuss.rubyonrails.org/t/cve-2022-21831-possible-code-injection-vulnerability-in-rails-active-storage/80199
* https://rubyonrails.org/2022/3/8/Rails-7-0-2-3-6-1-4-7-6-0-4-7-and-5-2-6-3-have-been-released
2022-03-09 01:14:09 -06:00
evazion
77c88fd867 Merge pull request #5038 from nonamethanks/remove-redundant-comments
sources: remove redundant comments
2022-03-08 23:28:29 -06:00
evazion
6afb2f8e3c Merge pull request #5037 from nonamethanks/tumblr-refactor
sources: factor out Source::URL::Tumblr
2022-03-08 23:26:30 -06:00
evazion
7d9790bf46 Merge pull request #5036 from NamelessContributor/issue-5006
icon_helper: inline globe_icon. fixes #5006
2022-03-08 23:22:22 -06:00
evazion
cf4b9a6114 Merge pull request #5039 from nonamethanks/simplify-lofter-tag-parsing
Lofter: simplify tag extraction logic
2022-03-08 23:21:57 -06:00
evazion
987f2985d3 Merge pull request #5040 from nonamethanks/fix-weibo-404
Weibo: fix exception for deleted url
2022-03-08 23:08:37 -06:00
evazion
52a2d3418c pixiv: fixup bugs in 1c620f805.
* Fix error when uploading non-ugoira files.
* Fix sample image URLs not being rewritten to full images correctly. We
  have to get the full image URL from the API because given an
  /img-master/ URL, we don't know what the original file extension is.
2022-03-08 23:07:24 -06:00
nonamethanks
c9be77d1f8 Weibo: fix exception for deleted url 2022-03-09 05:31:38 +01:00