Skip to content

Paths and filenames are not necessarily UTF-8 #7225

Closed
@huonw

Description

@huonw
$ mkdir empty
$ cd empty
$ ls
$ touch $(echo -e "\xff") # `ÿ` in latin1, invalid UTF8, but valid filename
$ ls
?
$ rusti
WARNING: The Rust REPL is experimental and may be
unstable. If you encounter problems, please use the
compiler instead. Type :help for help.
rusti> std::os::list_dir(&Path("."))
rust: task failed at 'assertion failed: is_utf8(v)', /home/huon/rust/src/libstd/str.rs:758
terminate called after throwing an instance of 'rust_task*'
Aborted

Path and all interfaces directly with the file-system should probably use [u8] rather than trying to coerce str to handle these cases. (Similar issue to #7188.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions