Skip to content

compose: Enforce max topic/content length by Unicode code points, not UTF-16 code units #1238

Closed
@chrisbobbe

Description

@chrisbobbe

We have this comment where we decide if the content input is too long:

      // normalized.length is the number of UTF-16 code units, while the server
      // API expresses the max in Unicode code points. So this comparison will
      // be conservative and may cut the user off shorter than necessary.
      if (textNormalized.length > kMaxMessageLengthCodePoints)

This issue is to stop cutting the user off shorter than necessary, while not regressing on performance in the common case where the length isn't approaching the limit.

This applies equally to topic lengths, where the server limit is also expressed in Unicode code points. For example, on CZO where the topic limit is 60 code points, we're not accepting '👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦👨‍👩‍👦' (60 code points), but we should accept it because the server does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a-composeCompose box, autocomplete, attaching files/images

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions