spacecookie-1.0.0.2: Gopher server library and daemon
Stabilityexperimental
PortabilityPOSIX
Safe HaskellSafe-Inferred
LanguageHaskell2010

Network.Gopher.Util

Description

Helper utilities used within the library and the server which also could be useful for other application code.

Synopsis

Security

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

asciiToLower :: Word8 -> Word8 Source #

Transform a Word8 to lowercase if the solution is in bounds.

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

boolToMaybe :: Bool -> a -> Maybe a Source #

boolToMaybe True x == Just x
boolToMaybe False x == Nothing