diff options
author | Fedor Indutny <fedor@indutny.com> | 2016-03-02 14:43:39 +0300 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2016-03-02 21:25:04 +0300 |
commit | b010c8716498dca398e61c388859fea92296feb3 (patch) | |
tree | 7939c49278bcb05bdc34134a4bf4d1824355978a /src/string_bytes.cc | |
parent | 0eda5f503a2fae915ae152bd221b523762a0ef97 (diff) |
crypto, string_bytes: treat `buffer` str as `utf8`
Do not treat crypto inputs as `binary` strings, convert them to Buffers
using `new Buffer(..., 'utf8')`, or using newly updated StringBytes
APIs.
PR-URL: https://github.com/nodejs/node/pull/5522
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/string_bytes.cc')
-rw-r--r-- | src/string_bytes.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc index a916caf75e8..d9ca6e565eb 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -368,7 +368,6 @@ size_t StringBytes::Write(Isolate* isolate, switch (encoding) { case ASCII: case BINARY: - case BUFFER: if (is_extern && str->IsOneByte()) { memcpy(buf, data, nbytes); } else { @@ -379,6 +378,7 @@ size_t StringBytes::Write(Isolate* isolate, *chars_written = nbytes; break; + case BUFFER: case UTF8: nbytes = str->WriteUtf8(buf, buflen, chars_written, flags); break; @@ -480,11 +480,11 @@ size_t StringBytes::StorageSize(Isolate* isolate, switch (encoding) { case BINARY: - case BUFFER: case ASCII: data_size = str->Length(); break; + case BUFFER: case UTF8: // A single UCS2 codepoint never takes up more than 3 utf8 bytes. // It is an exercise for the caller to decide when a string is @@ -532,11 +532,11 @@ size_t StringBytes::Size(Isolate* isolate, switch (encoding) { case BINARY: - case BUFFER: case ASCII: data_size = str->Length(); break; + case BUFFER: case UTF8: data_size = str->Utf8Length(); break; |