Skip to content

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

@git-xiaomy

Description

@git-xiaomy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions