git style filename quoting controlled by core.quotePath
This is by no means complete, but escaping filenames in actionItemDesc does cover most commands. Note that for ActionItemBranchFilePath, the value is branch:file, and I choose to only quote the file part (if necessary). I considered quoting the whole thing. But, branch names cannot contain control characters, and while they can contain unicode, git coes not quote unicode when displaying branch names. So, it would be surprising for git-annex to quote unicode in a branch name. The find command is the most obvious command that still needs to be dealt with. There are probably other places that filenames also get displayed, eg embedded in error messages. Some other commands use ActionItemOther with a filename, I think that ActionItemOther should either be pre-sanitized, or should explicitly not be used for filenames, so that needs more work. When --json is used, unicode does not get escaped, but control characters were already escaped in json. (Key escaping may turn out to be needed, but I'm ignoring that for now.) Sponsored-by: unqueued on Patreon
This commit is contained in:
parent
81bc57322f
commit
d689a5b338
11 changed files with 78 additions and 45 deletions
25
Messages.hs
25
Messages.hs
|
@ -1,6 +1,6 @@
|
|||
{- git-annex output messages
|
||||
-
|
||||
- Copyright 2010-2021 Joey Hess <id@joeyh.name>
|
||||
- Copyright 2010-2023 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
@ -62,7 +62,6 @@ import Types.Messages
|
|||
import Types.ActionItem
|
||||
import Types.Concurrency
|
||||
import Types.Command (StartMessage(..), SeekInput)
|
||||
import Types.Transfer (transferKey)
|
||||
import Messages.Internal
|
||||
import Messages.Concurrent
|
||||
import Annex.Debug
|
||||
|
@ -76,11 +75,13 @@ showStart command file si = outputMessage json $
|
|||
where
|
||||
json = JSON.start command (Just file) Nothing si
|
||||
|
||||
showStartKey :: String -> Key -> ActionItem -> SeekInput -> Annex ()
|
||||
showStartKey command key ai si = outputMessage json $
|
||||
encodeBS command <> " " <> actionItemDesc ai <> " "
|
||||
showStartActionItem :: String -> ActionItem -> SeekInput -> Annex ()
|
||||
showStartActionItem command ai si = do
|
||||
qp <- coreQuotePath <$> Annex.getGitConfig
|
||||
outputMessage json $
|
||||
encodeBS command <> " " <> actionItemDesc qp ai <> " "
|
||||
where
|
||||
json = JSON.start command (actionItemFile ai) (Just key) si
|
||||
json = JSON.start command (actionItemFile ai) (actionItemKey ai) si
|
||||
|
||||
showStartOther :: String -> Maybe String -> SeekInput -> Annex ()
|
||||
showStartOther command mdesc si = outputMessage json $ encodeBS $
|
||||
|
@ -90,11 +91,11 @@ showStartOther command mdesc si = outputMessage json $ encodeBS $
|
|||
|
||||
showStartMessage :: StartMessage -> Annex ()
|
||||
showStartMessage (StartMessage command ai si) = case ai of
|
||||
ActionItemAssociatedFile _ k -> showStartKey command k ai si
|
||||
ActionItemKey k -> showStartKey command k ai si
|
||||
ActionItemBranchFilePath _ k -> showStartKey command k ai si
|
||||
ActionItemFailedTransfer t _ -> showStartKey command (transferKey t) ai si
|
||||
ActionItemTreeFile file -> showStart command file si
|
||||
ActionItemAssociatedFile _ _ -> showStartActionItem command ai si
|
||||
ActionItemKey _ -> showStartActionItem command ai si
|
||||
ActionItemBranchFilePath _ _ -> showStartActionItem command ai si
|
||||
ActionItemFailedTransfer _ _ -> showStartActionItem command ai si
|
||||
ActionItemTreeFile _ -> showStartActionItem command ai si
|
||||
ActionItemOther msg -> showStartOther command msg si
|
||||
OnlyActionOn _ ai' -> showStartMessage (StartMessage command ai' si)
|
||||
showStartMessage (StartUsualMessages command ai si) = do
|
||||
|
@ -235,7 +236,7 @@ showFullJSON v = withMessageState $ bufferJSON (JSON.complete v)
|
|||
{- Performs an action that outputs nonstandard/customized output, and
|
||||
- in JSON mode wraps its output in JSON.start and JSON.end, so it's
|
||||
- a complete JSON document.
|
||||
- This is only needed when showStart and showEndOk is not used.
|
||||
- This is only needed when showStart* and showEndOk is not used.
|
||||
-}
|
||||
showCustom :: String -> SeekInput -> Annex Bool -> Annex ()
|
||||
showCustom command si a = do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue