Skip to content

Commit

Permalink
fixed decoding hex & base64 from two bytes external strings
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Cong Liu authored and rogerwang committed Nov 11, 2016
1 parent dea53d7 commit 5791b21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/string_bytes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,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);
Expand All @@ -332,7 +332,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);
Expand Down

0 comments on commit 5791b21

Please sign in to comment.