FurryCoders / FAAPI

Python library to implement API-like functionality for the FurAffinity.net website.
European Union Public License 1.2
20 stars 6 forks source link

[Bug]: HTML URL Encoded Usernames #5

Closed Xraydylan closed 1 year ago

Xraydylan commented 1 year ago

Version

3.9.1

What happened?

I have been using the API for a little project of mine and encountered a problem with a certain username.

In their name ["Basque`"] they use the " ` " character. It gets encoded in the URL with %60. (Reference for URL encoding https://www.w3schools.com/tags/ref_urlencode.ASP)

The problme is I can't get this user with the API's user() method. It doesn't throuw an error but insteads retrieves the user named "basque" without the speical character.

How can this be adressed?

How to reproduce the bug?

Call:

api.user("Basque`")

And compare stats to user front page of path "/user/Basque%60".

Relevant log output

No response

MatteoCampinoti94 commented 1 year ago

It's caused by an internal function that cleans up the username to avoid non-allowed characters (it removes everything that isn't a-z\d.~-). I didn't know ` was allowed, so the regex removes that too.

I'll add it to the list of allowed character and publish a patch :)

MatteoCampinoti94 commented 1 year ago

Fixed in v3.9.2 :)

Xraydylan commented 1 year ago

Thanks that would be good.

Alternatively, I just looked into it a bit. Would be be possible to use the quote() function from urllib.parse to achive a more consitent result if future error occure? (For the "Basque`" -> "Basque%60" conversion of similar characters?)

MatteoCampinoti94 commented 1 year ago

Yeah I thought about using quote, but I had already pushed the new version x3

I'll add it to the next patch :)

For what it's worth I tested it in my browsers and it worked without escaping the character. Modern browsers aren't that picky about escaping characters anymore, except for ? and & for query parameters.