okio icon indicating copy to clipboard operation
okio copied to clipboard

String.toPath() replaces back slashes in file names with a forward slash

Open colinrtwhite opened this issue 3 years ago • 0 comments

String.toPath() replaces consecutive back slash characters with Path.DIRECTORY_SEPARATOR (a single forward slash on android). This can cause issues if attempting to read a file with back slashes in its name using the FileSystem API. Here's a failing test case:

assertEquals(
    expected = "/absolute/path/to/file\\\\\\_with_slash_in_name.txt",
    actual = "/absolute/path/to/file\\\\\\_with_slash_in_name.txt".toPath().toString()
)

// actual returns "/absolute/path/to/file/_with_slash_in_name.txt"

Reproduced in Okio 3.0.0 and 3.1.0.

More context: https://github.com/coil-kt/coil/issues/1274

colinrtwhite avatar May 30 '22 23:05 colinrtwhite