filter out control characters in warning messages
Converted warning and similar to use StringContainingQuotedPath. Most warnings are static strings, some do refer to filepaths that need to be quoted, and others don't need quoting. Note that, since quote filters out control characters of even UnquotedString, this makes all warnings safe, even when an attacker sneaks in a control character in some other way. When json is being output, no quoting is done, since json gets its own quoting. This does, as a side effect, make warning messages in json output not be indented. The indentation is only needed to offset warning messages underneath the display of the file they apply to, so that's ok. Sponsored-by: Brett Eisenberg on Patreon
This commit is contained in:
parent
007e302637
commit
3290a09a70
75 changed files with 259 additions and 229 deletions
|
@ -192,7 +192,7 @@ accountCommandAction startmsg cleanup = tryNonAsync cleanup >>= \case
|
|||
Left err -> case fromException err of
|
||||
Just exitcode -> liftIO $ exitWith exitcode
|
||||
Nothing -> do
|
||||
toplevelWarning True (show err)
|
||||
toplevelWarning True (UnquotedString (show err))
|
||||
showEndMessage startmsg False
|
||||
incerr
|
||||
where
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances #-}
|
||||
{-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings #-}
|
||||
|
||||
module CmdLine.GitAnnex.Options where
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module CmdLine.Seek where
|
||||
|
||||
import Annex.Common
|
||||
|
@ -566,9 +568,9 @@ workTreeItems' (AllowHidden allowhidden) ww ps = case ww of
|
|||
let p' = toRawFilePath p
|
||||
relf <- liftIO $ relPathCwdToFile p'
|
||||
ifM (not <$> (exists p' <||> hidden currbranch relf))
|
||||
( prob (p ++ " not found")
|
||||
( prob (QuotedPath (toRawFilePath p) <> " not found")
|
||||
, ifM (viasymlink stopattop (upFrom relf))
|
||||
( prob (p ++ " is beyond a symbolic link")
|
||||
( prob (QuotedPath (toRawFilePath p) <> " is beyond a symbolic link")
|
||||
, return True
|
||||
)
|
||||
)
|
||||
|
@ -628,7 +630,7 @@ mkCheckTimeLimit = Annex.getState Annex.timelimit >>= \case
|
|||
swapTVar warningshownv True
|
||||
unless warningshown $ do
|
||||
Annex.changeState $ \s -> s { Annex.reachedlimit = True }
|
||||
warning $ "Time limit (" ++ fromDuration duration ++ ") reached! Shutting down..."
|
||||
warning $ UnquotedString $ "Time limit (" ++ fromDuration duration ++ ") reached! Shutting down..."
|
||||
cleanup
|
||||
else a
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue