summaryrefslogtreecommitdiff
path: root/src/string_bytes.cc
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2016-03-02 14:43:39 +0300
committerFedor Indutny <fedor@indutny.com>2016-03-02 21:25:04 +0300
commitb010c8716498dca398e61c388859fea92296feb3 (patch)
tree7939c49278bcb05bdc34134a4bf4d1824355978a /src/string_bytes.cc
parent0eda5f503a2fae915ae152bd221b523762a0ef97 (diff)
downloadandroid-node-v8-b010c8716498dca398e61c388859fea92296feb3.tar.gz
android-node-v8-b010c8716498dca398e61c388859fea92296feb3.tar.bz2
android-node-v8-b010c8716498dca398e61c388859fea92296feb3.zip
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.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc
index a916caf75e..d9ca6e565e 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;