From 368b69c0af32959cdf72a0b0b18109a6b7d57ca6 Mon Sep 17 00:00:00 2001 From: Cong Liu Date: Wed, 6 Jul 2016 20:31:27 +0800 Subject: [PATCH] fixed decoding hex & base64 from two bytes external strings Strings in DOM may be converted to two bytes representation, which should be processed as array of `uint16_t` when decoding hex or base64. base64 decoding in Node.js can fallback to a slow implementation to skip invalid characters (i.e. `\0` in this case). This patch can also keep base64 decoding running under the fast implementation. fixed nwjs/nw.js#5069 --- src/string_bytes.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/string_bytes.cc b/src/string_bytes.cc index fa641af7469..ef8e4d02545 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -335,7 +335,7 @@ size_t StringBytes::Write(Isolate* isolate, } case BASE64: - if (is_extern) { + if (is_extern && str->IsExternalOneByte()) { nbytes = base64_decode(buf, buflen, data, external_nbytes); } else { String::Value value(str); @@ -347,7 +347,7 @@ size_t StringBytes::Write(Isolate* isolate, break; case HEX: - if (is_extern) { + if (is_extern && str->IsExternalOneByte()) { nbytes = hex_decode(buf, buflen, data, external_nbytes); } else { String::Value value(str);