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

FormatException: Unexpected extension byte" Error with Non-UTF-8 File Names #95

Open
git-xiaomy opened this issue Jan 5, 2024 · 0 comments

Comments

@git-xiaomy
Copy link

Problem Description
I encountered a FormatException error while using the dartssh2 library for SFTP operations when directories contain filenames with special characters. The error message is as follows:

''' sh
FormatException: Unexpected extension byte (at offset 1)
#0 _Utf8Decoder.convertSingle (dart:convert-patch/convert_patch.dart:1747:7)
#1 Utf8Decoder.convert (dart:convert/utf.dart:351:42)
#2 Utf8Codec.decode (dart:convert/utf.dart:63:20)
#3 SSHMessageReader.readUtf8 (package:dartssh2/src/ssh_message.dart:75:17)
...

This issue seems to occur when trying to decode byte data into a UTF-8 string. The problem arises if filenames in the directory do not conform to the UTF-8 encoding standard.

Steps to Reproduce
Connect to an SFTP server.
Try to list a directory containing non-UTF-8 encoded filenames.
Observe the FormatException error.
Expected Behavior
The dartssh2 library should be able to handle filenames with special characters, even if they are not UTF-8 encoded, without throwing an exception.

Request
Please consider adding support for non-UTF-8 encoded filenames, or provide a way to gracefully handle these cases, such as using replacement characters for parts that cannot be decoded.

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

No branches or pull requests

1 participant