summaryrefslogtreecommitdiff
path: root/Fields.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-07-02 11:08:50 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-07-02 11:10:17 -0400
commitbdcabb3cfa0a7d14a35a6bcf34f9379e8900f556 (patch)
treed1b0c47a1a5ca7c77d671038ea37dadf9238c536 /Fields.hs
parent8f6c2e6081d8e162f34ff5406e8d564dc1b5f4a5 (diff)
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
Diffstat (limited to 'Fields.hs')
-rw-r--r--Fields.hs10
1 files changed, 5 insertions, 5 deletions
diff --git a/Fields.hs b/Fields.hs
index 08189cbdf..38427ad05 100644
--- a/Fields.hs
+++ b/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