From 4e176f378c253419eb7fa27820efade3657a1c0b Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 16 Apr 2011 18:09:32 -0400 Subject: [PATCH] Don't canonicalize paths in tv_rename, which allows us to remove paths.Verify() --- src/paths.go | 10 ---------- src/tv_rename.go | 18 +----------------- 2 files changed, 1 insertion(+), 27 deletions(-) diff --git a/src/paths.go b/src/paths.go index 27b92c1..428c9b2 100644 --- a/src/paths.go +++ b/src/paths.go @@ -41,16 +41,6 @@ func checkInJail(the_path string) bool { return true } -// Verifies that the path is in the jail and returns the cleaned-up path. Will -// return nil on error. -func Verify(thePath string) *string { - fullPath := canonicalizePath(thePath) - if !checkInJail(fullPath) { - return nil - } - return &fullPath -} - func List(the_path string) (files vector.StringVector, err os.Error) { full_path := canonicalizePath(the_path) if !checkInJail(full_path) { diff --git a/src/tv_rename.go b/src/tv_rename.go index f07fc04..b331f7a 100644 --- a/src/tv_rename.go +++ b/src/tv_rename.go @@ -19,29 +19,13 @@ import ( "regexp" "strconv" "strings" - "./paths" ) // Takes a full file path and renames the last path component as if it were a // TV episode. This performs the actual rename as well. func RenameEpisode(inPath string) (*string, os.Error) { - // Make sure a path was given. - if len(inPath) < 1 { - return nil, os.NewError("Invalid path") - } - // Check that it's inside the jail. - var safePath *string = paths.Verify(inPath) - if safePath == nil { - return nil, os.NewError("Path is invalid or outside of jail") - } - // Make sure that the file exists. - _, err := os.Stat(*safePath) - if err != nil { - return nil, err - } - // Parse the filename into its components. - dirName, fileName := path.Split(*safePath) + dirName, fileName := path.Split(inPath) info := parseEpisodeName(fileName) if info == nil { return nil, os.NewError("Could not parse file name") -- 2.22.5