refactor(lpr): sanitizing cmd argument properly
This commit is contained in:
parent
6d7209b3da
commit
68bd7ff51b
@ -333,10 +333,12 @@ readProcess' pc = do
|
||||
|
||||
sanitizeCmdArg :: Text -> Text
|
||||
sanitizeCmdArg t =
|
||||
T.snoc (T.cons '"' $ T.filter (\c -> '"' /= c && '\\' /= c) t) '"'
|
||||
T.snoc (T.cons '\'' $ T.filter (\c -> '\'' /= c && '"' /= c && '\\' /= c) t) '\''
|
||||
-- | Pin Password is used as a commandline argument in Utils.Print.encryptPDF and hence poses a security risk
|
||||
validCmdArgument :: Text -> Bool
|
||||
validCmdArgument t = not (T.null t) && (T.cons '"' (T.snoc t '"') == sanitizeCmdArg t)
|
||||
validCmdArgument t = not (T.null t) && (T.cons '\'' (T.snoc t '\'') == sanitizeCmdArg t)
|
||||
|
||||
|
||||
|
||||
-----------
|
||||
-- pdftk --
|
||||
|
||||
Loading…
Reference in New Issue
Block a user