Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5150

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

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

      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 Unassigned
            Reporter:
            bailey.pearson@mongodb.com Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: