Commit Graph

9836 Commits

Author SHA1 Message Date
evazion
25cba710bf BURs: don't allow requesting implications that already exist.
Fix it being possible to request duplicate implications.
2020-11-12 20:15:14 -06:00
evazion
654d2175b6 aliases/implications: remove processing state.
Remove the `processing` state from aliases and implications. This state
was used to mark when an alias or implication had been approved but the
alias or implication was still being processed. Aliases in the
processing state were still considered active, so there was no
functional difference between the active state and the processing state.

This fixes a problem where it was possible for implications to get stuck
in the processing state. This happened when a BUR contained a duplicate
implication. Transitioning from the processing state to the active state
failed in this case because we used `update` instead of `update!`, which
meant validation errors were silently ignored.
2020-11-12 18:22:51 -06:00
evazion
5844f16ed6 BURs: make rename command move aliases/implications.
Make the tag rename command also move any aliases or implications from
the old tag to the new tag. Previously only the create alias command
moved aliases and implications.
2020-11-12 17:12:09 -06:00
evazion
9a287cd71f Fix #4483: Wrong order for BUR caused 12k mistags.
Bug: if a BUR contained a mass update followed by an alias, then the
alias would become active before the mass update, which could cause
the mass update to return incorrect results if both the alias and mass
update touched the same tags.

This happened because all aliases and implications in the BUR were set
to a queued state before the mass update was processed, but putting an
alias in the queued state effectively made it active.

The fix is to remove the queued state. This was only used anyway as a
debugging tool anyway to monitor the state of BURs as they were being
processed.
2020-11-12 16:09:56 -06:00
evazion
cc64f8b7ee tests: fix broken source tests.
Fix various tests broken by source files changing or being deleted.
2020-11-10 14:52:54 -06:00
evazion
3ce8c7f004 Update ruby gems and yarn packages. 2020-11-10 14:02:10 -06:00
evazion
f9a44ab192 Temp disable popular tags and news banner.
Emergency measure to to reduce load on Redis.
2020-11-09 13:33:24 -06:00
evazion
aa2d04322a users: fix not being able to verify account with certain valid emails.
Bug: Verifying your account with a hotmail.com email address didn't mark
your account as verified. This was because the list of allowed email
verification domains only included normalized domains, but we were
looking up unnormalized domains.
2020-09-21 15:06:47 -05:00
evazion
f2d611ba69 reportbooru: raise http timeout.
Fetching missed searches from Reportbooru sometimes failed because the
0.5 second HTTP timeout was too low.
2020-09-21 13:29:53 -05:00
evazion
9f3a9ac4e1 Update ruby gems and yarn packages. 2020-09-14 13:00:31 -05:00
evazion
0e688f8e65 reportbooru: decrease http timeout, increase cache length.
Decrease the HTTP timeout to 0.5 seconds when fetching popular tags from
Reportbooru. Increase the length of time that popular tags are cached
from 1 minute to 1 hour. This is for the list of popular searches in the
front page sidebar.
2020-09-14 12:53:41 -05:00
evazion
5dd3027d0c Revert "posts: disable popular searches in sidebar."
This reverts commit c830973bd4.
2020-09-14 12:49:22 -05:00
evazion
c830973bd4 posts: disable popular searches in sidebar. 2020-09-04 14:25:51 -05:00
evazion
d489612289 Update ruby gems and yarn packages. 2020-09-04 11:48:10 -05:00
evazion
d7866285cd post versions: move all/any changed tags to advanced search. 2020-08-31 17:47:20 -05:00
evazion
6320db2541 BURs: fix rewriting wiki links with qualifiers.
When renaming a tag and the new tag has a qualifier, use the pipe trick
to hide the qualifier in wiki links. For example, renaming Fallout to
Fallout_(series) should change wiki links from [[Fallout]] to [[Fallout
(series)|]].
2020-08-28 13:57:18 -05:00
evazion
7bc7001b12 dmails: add dmail sending rate limits.
Don't allow regular users to send dmails to more than 10 different
users in one hour. This is an anti-spam measure.
2020-08-28 12:36:42 -05:00
evazion
5baeb3eecc dmails: update unread dmail count when dmail is hard deleted.
When a dmail is hard deleted, update the user's unread dmail count and
delete any associated mod reports.

Dmails aren't normally hard deleted, except when there's a large spam
wave that necessitates manual intervention.
2020-08-28 11:28:28 -05:00
evazion
319a2c011f Update ruby gems and yarn packages. 2020-08-27 22:57:06 -05:00
evazion
b37fa87d4b posts: fix bug preventing *_(cosplay) tags from being added.
Bug: if `hatsune_miku` is an empty general tag, then tagging a post with
`hatsune_miku_(cosplay)` would fail because `hatsune_miku` wasn't a
character tag. This could cause tagging posts to fail when aliasing a
character tag back to an old name that was used in the past, but was now
an empty general tag.

Fix: only treat the *_(cosplay) tag as being in conflict with the base
tag when the base tag is nonempty.
2020-08-27 22:39:16 -05:00
evazion
346b143e40 Fix #4599: Editing saved search fails when user has maximum saved searches. 2020-08-27 22:25:16 -05:00
evazion
7770c38d0d saved searches: rearrange macros.
Move macros to the top of file, as they should be.
2020-08-27 21:39:49 -05:00
evazion
b9d904ac76 BURs: move cosplay tags when moving character tags.
When aliasing or renaming a character tag, move the corresponding
*_(cosplay) tag if it exists.
2020-08-27 21:38:26 -05:00
evazion
23944a1794 Fix #4491: Have tag rename option for bulk update requests.
* Add a `rename A -> B` command for bulk update requests.
* Change mass updates to only retag the posts, not to move saved
  searches or blacklists.

A tag rename does the same thing an alias does, except it doesn't
create a permanent alias. More precisely, a tag rename:

* Moves the wiki.
* Moves the artist entry.
* Moves saved searches.
* Moves blacklists.
* Merges the wikis, if both tags have wiki pages.
* Merges the artist entries, if both tags have artist pages.
* Fixes links in wiki pages to point to the new tag.
* Retags the posts.
2020-08-26 19:53:04 -05:00
evazion
bbf2b53d83 aliases: fix broken wiki links when aliasing tags.
When aliasing A to B, update any wikis linking to [[A]] to link to [[B]]
instead.

This is a best-effort process based on rough heuristics. There are a few
known problems:

* We don't always know how to capitalize the new tag. We try to mimic
  the capitalization of the old tag, such that if the old tag was
  capitalized (because it was at the beginning of a sentence), or if
  every word in the old link was capitalized (because it's a proper
  noun), then the new link will be capitalized in the same way. This can
  handle simple general tags and character tags, but will fail for
  copyright tags with mixed capitalization. For example, we don't know
  that [[jojo_no_kimyou_na_bouken]] should be capitalized as [[JoJo no
  Kimyou na Bouken]]. If we don't know how to capitalize the new tag, we
  leave the old tag as-is so it can manually be fixed.

* Some aliases might require changing how a tag is pluralized. If we
  changed [[rat]] to [[mouse]], then we should change `[[rat]]s` to
  [[mice]]. We don't try to deal with this.

* In general, some changes might require entire sentences to be
  rewritten to keep the grammar correct. Changing something like
  [[skirt lift]] to [[lifting skirt]] could break the grammar of the
  sentence. We don't try to deal with this.
2020-08-26 19:02:19 -05:00
evazion
f4f25cf0c8 aliases: fix blacklists when aliasing tags.
When aliasing a tag, update any blacklists containing the old tag to use
the new tag.
2020-08-26 17:06:00 -05:00
evazion
f0299a8945 aliases: refactor tag moving code.
* Factor out the code for moving tags from tag aliases to a separate
  TagMover class.

* When aliasing two tags that have conflicting wikis, merge the old wiki
  into the new one instead of failing with an error. Merge the other names
  fields, replace the old wiki body with a message linking to the new
  wiki, and mark the old wiki as deleted.

* When aliasing two tags that have conflicting artist entries, merge the
  old artist into the new one instead of silently ignore the conflict.
  Merge the group name, other names, and urls fields, and mark the old
  artist as deleted.

* When two tags have conflicting wikis or artist entries, but the old
  wiki or artist entry is deleted, then just ignore the old wiki or
  artist and don't try to merge it.

* Fix it so that when saved searches are rewritten, we rewrite negated
  searches too.
2020-08-26 17:05:41 -05:00
evazion
44402299ec BURs: remove unused alternate forms of commands.
Remove the following alternate forms of commands:

* aliasing A -> B
* unaliasing A -> B
* implicating A -> B
* implicate A -> B
* unimplicating A -> B
* unimplicate A -> B
* updating A -> B
* change A -> B

The following forms are accepted:

* create alias A -> B
* alias A -> B
* create implication A -> B
* imply A -> B
* remove alias A -> B
* unalias A -> B
* remove implication A -> B
* unimply A -> B
* update A -> B
2020-08-24 18:00:35 -05:00
evazion
d9085877be BURs: fix normalization of uppercase characters in scripts.
Only downcase tags in aliases, implications, and category change
commands. Don't downcase mass update commands. Mass updates are
potentially case sensitive (for example: `mass update source:imageboard -> source:Imageboard`).
2020-08-24 17:54:53 -05:00
evazion
1ddcc661e1 BURs: clean up parsing and error handling.
* Don't raise exceptions when a BUR is invalid. Instead, use Rails
  validations to return errors. Fixes invalid BURs potentially raising
  exceptions in views. Also makes it so that each error in a BUR is
  reported, not just the first one.

* Revalidate the BUR whenever the script is edited, not just when the
  BUR is created. Ensures the BUR can't be broken by editing. Fixes a bug
  where forum threads could be broken by someone editing a BUR and
  breaking the syntax, thereby causing the BUR to raise an unparseable
  script error when the forum thread was viewed.

* Validate that removed aliases and implication actually exist.

* Validate that the tag actually exists when changing a tag's category.

* Combine bulk update request processor unit tests with main bulk update
  request unit tests.
2020-08-24 17:10:48 -05:00
evazion
c295e233f2 Fix #4597: <code> blocks no longer render as monospace for notes. 2020-08-21 21:14:42 -05:00
evazion
49c15e1de7 artists: blacklist reddit.com from artist finder. 2020-08-20 20:09:07 -05:00
evazion
a79aad443d tag relationships: fix typo in consequent_wiki association.
The consequent_wiki association incorrectly used the antecedent wiki.
This caused wiki conflict errors when approving aliases.
2020-08-19 17:04:25 -05:00
evazion
f923d17072 Fix #4593: Shift + F shortcut not working correctly.
Fix it being possible to use Shift+F to unfavorite a post that is
already not favorited.
2020-08-18 15:34:12 -05:00
evazion
1d2a8a7898 fanbox: don't raise error on age-restricted posts.
Prevent age-restricted fanbox posts from raising errors when source data
is fetched. This prevents error messages from being shown to users when
switching to the edit tab on a post.

This will cause uploads of age-restricted posts to fail with an
unrelated error because we either can't find the image url (if we were
given only the html page) or we can't download the image (because we're
not logged in to Fanbox).
2020-08-18 15:34:12 -05:00
evazion
5bad5c6012 comments: fix visible method conflict.
Fix the `Comment#visible` method conflicting with the base class
`visible` method defined in ApplicationRecord.
2020-08-18 15:34:12 -05:00
evazion
70b82010a7 search: fix info leak when searching nested associations.
Fix an exploit in #4553. It was possible to use nested searches to infer
the contents of private forum posts.

For example:

* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=h*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=he*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=hel*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=hell*
* https://danbooru.donmai.us/users?search[forum_posts][id]=121683&search[forum_posts][body_matches]=hello*

The above searches returned the user 'albert', indicating that the
private forum post with id 121683 starts with the word 'hello'.

By guessing the id of a private forum post (which can be done by
searching for gaps in the id sequence), and by guessing text within the
post (which can be done by sequentially guessing characters with
wildcard searches), one could eventually infer the full text of a
private forum post.

The fix is to make nested searches only return records that are visible
to the current user.
2020-08-18 15:21:39 -05:00
evazion
86c376e90d Merge pull request #4590 from nonamethanks/nijie_doujinshi
Nijie: Add doujin support
2020-08-18 14:59:18 -05:00
evazion
0c96c2172c Merge pull request #4577 from nonamethanks/fanbox
Add (partial) fanbox support
2020-08-18 14:13:43 -05:00
evazion
e35d130b65 Merge pull request #4594 from BrokenEagle/fix-parameter-hash-check
Fix parameter hash detection
2020-08-18 12:20:43 -05:00
evazion
4c3b4671ef ip addresses: fix exception on ip_addresses/show page. 2020-08-18 11:16:26 -05:00
evazion
fee68b6dd9 css: fix input box size in inline forms. 2020-08-18 11:08:02 -05:00
evazion
d98dd0bb6d ugoiras: don't initialize notes on ugoiras.
Fixes note font scaling increasing the size of the ugoira playback controls.
2020-08-18 11:06:19 -05:00
BrokenEagle
36fa8efcd5 Fix parameter hash detection
Hash-like objects will respond to each_value, whereas arrays do not.
2020-08-18 05:34:14 +00:00
evazion
975d42c9ac posts: move artist tags to the top of the tag list. 2020-08-17 22:33:18 -05:00
evazion
937653e519 models: move html_data_attributes to policies.
Move html_data_attributes definitions from models to policies. Which
attributes are permitted as data-* attributes is a view level concern
and should be defined on the policy level, not the model level. Models
should be agnostic about how they're used in views.
2020-08-17 22:33:18 -05:00
evazion
4b18361aaf tumblr: fix uses of $ in regexes. 2020-08-17 15:31:18 -05:00
evazion
160b099445 sources: use http client from base strategy. 2020-08-17 15:30:01 -05:00
evazion
e196514de8 tests: fix test failures in #4553. 2020-08-17 15:19:34 -05:00
evazion
e5f459bd52 ci: remove merge conflict notifier job.
Seems to be broken and it's not worth debugging.
2020-08-17 14:47:43 -05:00