client metadata appName truncation breaks when unicode characters straddle the 128th byte

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Connection Layer
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      makeClientMetadata truncates the appname using Buffer.subarray() and buffer.toString('utf8'):

       

        Buffer
          .from(appName, 'utf8')
          .subarray(0, 128).toString('utf8')

      This breaks when encoding a string that has a multi-byte unicode character that straddles the 128th byte in the array because `toString('utf8')' replaces the invalid bytes with the unicode replacement character:

       

       

      Buffer.byteLength(
        Buffer
          .from('€'.repeat(300), 'utf8')
          .subarray(0, 128)
          .toString('utf8')) // 129 

      Acceptance Criteria

      Fix our string length truncation so that we never produce a string that's > 128 bytes. 

       

       

            Assignee:
            Unassigned
            Reporter:
            Bailey Pearson
            None
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: