Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

string_decoder and V8 decoder misaligned in edge case #22626

Closed
addaleax opened this issue Aug 31, 2018 · 0 comments
Closed

string_decoder and V8 decoder misaligned in edge case #22626

addaleax opened this issue Aug 31, 2018 · 0 comments
Assignees
Labels
string_decoder Issues and PRs related to the string_decoder subsystem.

Comments

@addaleax
Copy link
Member

  • Version: 8 and above (but fixing might be semver-major)
  • Subsystem: string_decoder
'use strict';
const { StringDecoder } = require('string_decoder');

const bufs = [
  Buffer.from('f6', 'hex'),
  Buffer.from('9b', 'hex'),
  Buffer.from('d1', 'hex')
];

const sd = new StringDecoder('utf8');
let str = '';
for (const buf of bufs)
  str += sd.write(buf);
str += sd.end();

console.log(`str = ${str}`)  // 2 replacement chars
console.log(`orig = ${Buffer.concat(bufs).toString()}`)  // 3 replacement chars

Haven’t really looked into this yet, so anybody who’d like to can feel free to do so.

@addaleax addaleax added the string_decoder Issues and PRs related to the string_decoder subsystem. label Aug 31, 2018
addaleax added a commit to addaleax/node that referenced this issue Sep 5, 2018
@addaleax addaleax self-assigned this Sep 5, 2018
addaleax added a commit that referenced this issue Sep 24, 2018
PR-URL: #22709
Fixes: #22626
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
string_decoder Issues and PRs related to the string_decoder subsystem.
Projects
None yet
Development

No branches or pull requests

1 participant