superseriousbusiness / gotosocial

Fast, fun, small ActivityPub server.
https://docs.gotosocial.org
GNU Affero General Public License v3.0
3.61k stars 303 forks source link

[bug] Pinafore disagrees with toot length when non-ASCII characters are used #946

Closed autumnull closed 1 year ago

autumnull commented 1 year ago

Describe the bug with a clear and concise description of what the bug is.

Pinafore disagrees with toot length when non-ASCII characters are used

What's your GoToSocial Version?

v0.5.2

GoToSocial Arch

armv7 Binary

Browser version

Firefox 106.0.2 (64-bit)

What happened?

What you expected to happen?

How to reproduce it?

Make a post with lots of unicode in it near the character limit.

Anything else we need to know?

This is probably because GoToSocial is using bytes to measure toot length, and pinafore is using unicode chars. Just a hunch.

tsmethurst commented 1 year ago

Ah, thanks! Indeed we just use len(someStringVar)

NyaaaWhatsUpDoc commented 1 year ago

Instead we need to be using len([]rune(str)), obviously the same should be done anywhere we're checking maximum length of user-inputtable strings that support non-ASCII.