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

fix sync.stat() failure for multibyte paths #127

Merged
merged 1 commit into from
Mar 3, 2020

Conversation

mhama
Copy link
Contributor

@mhama mhama commented Mar 3, 2020

About

client.stat() fails for files with multi-byte filename like "あああ.txt" (japanese filename)
This will fix the problem.

Root Cause:

In _sendCommandWithArg method, it uses arg.length for the binary payload size of arg. But if arg is multi-byte string, arg.length is wrong to be used for the purpose, because it is the count of characters and not the size of bytes.

Solution

Use Buffer.byteLength(arg, 'utf-8') as the binary payload size of arg.
see: https://nodejs.org/api/buffer.html#buffer_class_method_buffer_bytelength_string_encoding

Related

#86 may be fixed with this fix.

@koral-- koral-- merged commit bcf4421 into openstf:master Mar 3, 2020
@koral--
Copy link
Member

koral-- commented Mar 3, 2020

Thanks.

@koral-- koral-- mentioned this pull request Mar 3, 2020
@sunjw
Copy link

sunjw commented Apr 1, 2020

Please release a new version with this fix in npm. It affects all command in Sync, including pull and push.

pimterry pushed a commit to httptoolkit/adbkit that referenced this pull request Dec 13, 2021
* avoid “chunk is undefined”

Signed-off-by: renchao <renchao@huya.com>

* fix: avoid chunk maybe undefined

Signed-off-by: renchao <renchao@huya.com>

* avoid chunk is undefined

Signed-off-by: renchao <renchao@huya.com>

Co-authored-by: renchao <renchao@huya.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants