]> git.lizzy.rs Git - micro.git/commitdiff
Fix path escaping on Windows
authorZachary Yedidia <zyedidia@gmail.com>
Sat, 27 Jun 2020 21:59:28 +0000 (17:59 -0400)
committerZachary Yedidia <zyedidia@gmail.com>
Sat, 27 Jun 2020 21:59:28 +0000 (17:59 -0400)
Windows does not allow ':' in a path, but for some reason previous
versions still worked, except the file for storing buffer info
(which had a ':' in the name) was not viewable except by opening
it with micro.

Ref #1736

internal/util/util.go

index 8b867ca0b00d2458354d80e4e1daaeaf82e56cd2..317cd65d2a9824baebb26d560f5e5b536f155392 100644 (file)
@@ -336,6 +336,10 @@ func GetModTime(path string) (time.Time, error) {
 // EscapePath replaces every path separator in a given path with a %
 func EscapePath(path string) string {
        path = filepath.ToSlash(path)
+       if runtime.GOOS == "windows" {
+               // ':' is not valid in a path name on Windows but is ok on Unix
+               path = strings.Replace(path, ":", "%", -1)
+       }
        return strings.Replace(path, "/", "%", -1)
 }