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
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Remote.P2P (
|
||||
remote,
|
||||
chainGen
|
||||
|
@ -105,7 +107,7 @@ runProtoConn a c@(OpenConnection (runst, conn)) = do
|
|||
-- so close it.
|
||||
case v of
|
||||
Left e -> do
|
||||
warning $ "Lost connection to peer (" ++ describeProtoFailure e ++ ")"
|
||||
warning $ UnquotedString $ "Lost connection to peer (" ++ describeProtoFailure e ++ ")"
|
||||
liftIO $ closeConnection conn
|
||||
return (ClosedConnection, Nothing)
|
||||
Right r -> return (c, Just r)
|
||||
|
@ -163,9 +165,9 @@ openConnection u addr = do
|
|||
liftIO $ closeConnection conn
|
||||
return ClosedConnection
|
||||
Left e -> do
|
||||
warning $ "Problem communicating with peer. (" ++ describeProtoFailure e ++ ")"
|
||||
warning $ UnquotedString $ "Problem communicating with peer. (" ++ describeProtoFailure e ++ ")"
|
||||
liftIO $ closeConnection conn
|
||||
return ClosedConnection
|
||||
Left e -> do
|
||||
warning $ "Unable to connect to peer. (" ++ show e ++ ")"
|
||||
warning $ UnquotedString $ "Unable to connect to peer. (" ++ show e ++ ")"
|
||||
return ClosedConnection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue