fix associatedfile sanity check
It seems best to require that the file just be relative, and not some ../ trick. git-annex-shell sendkey and recvkey both update transfer information now
This commit is contained in:
parent
8f6c2e6081
commit
bdcabb3cfa
2 changed files with 8 additions and 8 deletions
10
Fields.hs
10
Fields.hs
|
@ -15,18 +15,18 @@ import Data.Char
|
|||
{- A field, stored in Annex state, with a value sanity checker. -}
|
||||
data Field = Field
|
||||
{ fieldName :: String
|
||||
, fieldCheck :: String -> IO Bool
|
||||
, fieldCheck :: String -> Bool
|
||||
}
|
||||
|
||||
remoteUUID :: Field
|
||||
remoteUUID = Field "remoteuuid" $
|
||||
-- does it look like a UUID?
|
||||
return . all (\c -> isAlphaNum c || c == '-')
|
||||
all (\c -> isAlphaNum c || c == '-')
|
||||
|
||||
associatedFile :: Field
|
||||
associatedFile = Field "associatedfile" $ \value ->
|
||||
-- is the file located within the current directory?
|
||||
dirContains <$> getCurrentDirectory <*> pure value
|
||||
associatedFile = Field "associatedfile" $ \f ->
|
||||
-- is the file a safe relative filename?
|
||||
not (isAbsolute f) && not ("../" `isPrefixOf` f)
|
||||
|
||||
getField :: Field -> Annex (Maybe String)
|
||||
getField = Annex.getField . fieldName
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue