Stability | experimental |
---|---|
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Helper utilities used within the library and the server which also could be useful for other application code.
Synopsis
- sanitizePath :: RawFilePath -> RawFilePath
- sanitizeIfNotUrl :: RawFilePath -> RawFilePath
- dropPrivileges :: String -> IO ()
- asciiOrd :: Char -> Word8
- asciiChr :: Word8 -> Char
- asciiToLower :: Word8 -> Word8
- uEncode :: String -> ByteString
- uDecode :: ByteString -> String
- stripNewline :: ByteString -> ByteString
- boolToMaybe :: Bool -> a -> Maybe a
Security
sanitizePath :: RawFilePath -> RawFilePath Source #
Normalise a path and prevent directory traversal attacks.
sanitizeIfNotUrl :: RawFilePath -> RawFilePath Source #
Use sanitizePath
except if the path starts with URL:
in which case the original string is returned.
dropPrivileges :: String -> IO () Source #
Call setGroupID
and setUserID
to switch to
the given user and their primary group.
Requires special privileges.
Will raise an exception if either the user
does not exist or the current user has no
permission to change UID/GID.
String Encoding
uEncode :: String -> ByteString Source #
Encode a String
to a UTF-8 ByteString
uDecode :: ByteString -> String Source #
Decode a UTF-8 ByteString
to a String
Misc Helpers
stripNewline :: ByteString -> ByteString Source #
Strip \r
and \n
from ByteString
s
boolToMaybe :: Bool -> a -> Maybe a Source #
boolToMaybe True x == Just x
boolToMaybe False x == Nothing