Skip to content

Fails to encode strings containing non-ASCII characters #1

Open

Description

@sorear

The browser encoder uses character length for strings, but the browser decoder, node encoder, and node decoder all expect byte lengths. This leads to hilarity at decode time.

Activity

  1. ericz commented on Apr 3, 2013

    @ericz
    Member

    Yes indeed. It's just hard to get byte lengths on client side in a performant manner. I'll probably make a UTF happy fork sometime by using (new Blob([str])).size instead of str.length sometime, but I don't want binarypack to be slow

  2. dnorman commented on Apr 3, 2013

    @dnorman

    I would agree that performance is important, but this malfunctions in a particularly egregious way when UTF8 data is passed, which is to say that it's quite vulnerable, as UTF8 is ever-present on the modern web. Notwithstanding this bug, binaryjs is an excellent library btw.

  3. ericz commented on Apr 3, 2013

    @ericz
    Member

    I see what you're saying.

    Any suggestion for solutions?

    Options:

    • Take a performance hit and get string lengths with (new Blob([str])).size instead of str.length
    • Offer a UTF8 flag / fork that takes the performance hit if people so desire
    • Do nothing

    Or other ideas?

  4. added a commit that references this issue on Dec 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions