Status: New
Owner: ----

New issue 1162 by [email protected]: Strings should terminate on null bytes in data passed to String::New() (even if a length is provided)
http://code.google.com/p/v8/issues/detail?id=1162

In many cases, you might have some data like this:

    "hello\0\0\0\0\0"

In this case, you know that you have 10 bytes, but it's null-padded, and you generally only want the first 5 bytes. If no length argument is passed to String::New(), then it'll do the right thing, and return a string containing "asdf".

However, if you call String::New(data, 10), then you'll get a string with a bunch of null characters in it.

I'd argue that \0 is in fact not valid Utf8, and is certainly not valid ASCII. Even if a length is provided, it should terminate if a null byte is encountered. You generally never want to see null characters if you're interpreting an array of bytes as ASCII or UTF-8.

Patch: http://codereview.chromium.org/6524031/

Signed contributor license agreement.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to