Protospace / spaceport

Calgary Protospace's member portal
https://my.protospace.ca
GNU Affero General Public License v3.0
13 stars 9 forks source link

Bug: character count broken in "Bio/Notes" section #107

Open DeflateAwning opened 1 year ago

DeflateAwning commented 1 year ago

Reproduction

  1. Login to Spaceport.
  2. Go to Member > Account.
  3. Type to follow (or maybe paste) into the Bio / Notes section:
    'aaaaaaaaaa aa aaaaa aaaaaaaaa aaaaaaaaaaa. aaaaaaaaaaaaa aaaa-aaaaaaaa aaaaaaa aaaaaaaa.  aaaaa aaaaaaaaaa aaaaaaaa (aaaaa aaa aaaa).  aaaaaaaaaa aa aaaaaaaaa aaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaa, aaaaaaaaa aaaaaaaaaaa, aaa aaaaaa, aaaaa (aaaa), aaa (aaaaaaaa, aaaaaa aaa), aaa aaa (aaaaaa, aaaaa, aaaaaa, aa), aaaa aaaaaaa, aaa/aaaaaa aaaaa/aaaaaa, aaaaaaaaaaaa aaaaaaa, aaaaa/aaaa, aaaaaaaa, aa aaaaaaa, aaaaaa, aaaaaaaaaa, aaaaaaaaaaa, aaaaaaaa aaa.  aaaaaa aaaaaaaa aa aaaaaaaaaa/aaaaaaaa aaaaaaaaaaa.
  4. See that the character count is only 507.
  5. Submit.
  6. Expect "512 chars exceeded" error.
  7. Scream about how your repro didn't fail again.

Proposed Problem

On Windows, browsers use a CR+LF line ending. JS doesn't count NL's as 2 bytes, but the server-side error check does. It looks like I have under 512 chars client-side, but the server errors because it counts LF's as chars.

Solution

On submit, server-side (and maybe client-side too) replace LF with null string.