ensure utf-8 nicknames on nickname GETs and user validator #1057
No reviewers
Labels
No labels
approved, awaiting change
broken setup
bug
cannot reproduce
configuration
documentation
duplicate
enhancement
extremely low priority
feature request
Fix it yourself
help wanted
invalid
mastodon_api
needs change/feedback
needs docs
needs tests
not a bug
not our bug
planned
pleroma_api
privacy
question
static_fe
triage
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AkkomaGang/akkoma!1057
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "user-utf8"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Shoves
String.valid?on user methods that hit the database as well as on the user validatorResolves #1055
yeah, it’s probably best to add the UTF-8 check directly into the
User.get_*functions, eventhough this unfortunately will also add the overhead to already known-good values. And rejecting insertion early in the validator is good toJust some minor tweaks
@ -1223,3 +1227,3 @@def get_cached_by_nickname_or_id(nickname_or_id, opts \\ []) dorestrict_to_local = Config.get([:instance, :limit_to_local_content])if String.valid?(nickname_or_id) doSince
FlakeIdcan handle this and id-type arguments are presumably much more common it might be good to optimise this by only testingString.validif there was no id match. E.g. something like:Though it might be nicer to split the "allowed to lookup" checks handled in the
condinto a private function returning a boolean and then also handle this as just anotherwithclause:i just removed the check in nickname_by_id and let it live in the get_cached_by_nickname which should be suitable
@ -1248,0 +1256,4 @@endelse:errorendReturning
:errorhere breaks the documented type spec. It apparently still works fine anyway for/api/v1/accounts/:nick, but might still crash for other users of this function. I don’t think it’s necessary to distinguish this from a normal "not found" response though, after all no such user exists in the db and so just returningnilseems fine.The same applies to the other two modified functions
@ -84,2 +85,4 @@end)enddefp validate_nickname(%{"preferredUsername" => nick}) when is_binary(nick) dowhat will happen if
"preferredusername"exists but isn’t a binary?updated to error if we have the preferredUsername key but its type is silly