]> cat aescling's git repositories - mastodon.git/commit
Improve `from` search prefix error handling (#37)
author0x2019 <34298117+single-right-quote@users.noreply.github.com>
Sat, 9 Apr 2022 23:39:24 +0000 (23:39 +0000)
committersingle-right-quote <11325618-aescling@users.noreply.gitlab.com>
Sun, 10 Apr 2022 03:59:03 +0000 (23:59 -0400)
commit2a1bce96eefb737ed9957ba3ca7f6bc0981bb6ca
tree152d67beb420f015c1542aafb14a8dc1fac17ed2
parentf9ca54d8477bcd84740b847f74e7ed0a40e07ff4
Improve `from` search prefix error handling (#37)

* Make `from` search prefix more robust (addresses mastodon/mastodon#17941)

* Improve robustness for account string validation

Using unsupported prefixes now reports a 422; searching for posts from an
account the instance is not aware of reports a 404. TODO: The UI for this
on the front end is abysmal.

Searching `from:username@domain` now succeeds when `domain` is the local
domain; searching `from:@username(@domain)?` now works as expected.

* Satisfy upstream rubcocp

* Unbreak upstream tests

* Make account string validation consistent with mention processing

We previously matched on one-character domains and domains ending with
`[\.-]`, allowing `from:@a@a` and `from:@a@a-` searches to cause an
account lookup. This commit will raise a syntax error in both cases, as
MENTION_RE would never match them.

* Refactor `from` prefix error handling.

Incorporates changes suggested in #37. In doing so, adopts an error
handling style more consistent with the existing codebase (for which I
must thank @ClearlyClaire).

Removes new code no longer in use.
app/controllers/api/v2/search_controller.rb
app/lib/search_query_transformer.rb
app/models/concerns/account_finder_concern.rb
lib/exceptions.rb