Skip to content

Commit

Permalink
URL-encode "," and ":" characters, which could confuse annotation par…
Browse files Browse the repository at this point in the history
…sing.
  • Loading branch information
chungyc committed Feb 5, 2025
1 parent bbdc00d commit 6ad9b2d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/SpecialOutput.hs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ toAnnotation v = do
title' <- title
let annotation =
mconcat
[ "::" <> level' <> " ",
[ "::" <> escapeSpecial level' <> " ",
location,
"title=" <> title' <> "::",
message'
"title=" <> escapeSpecial title' <> "::",
escapeNewlines message'
]
return $ escapeNewlines annotation <> "\n"
where
Expand Down Expand Up @@ -153,7 +153,7 @@ locationAnnotation v =
]
where
fileAnnotation
| (Just s) <- filename = "file=" <> s <> ", "
| (Just s) <- filename = "file=" <> escapeSpecial s <> ", "
| otherwise = ""

colAnnotation
Expand Down Expand Up @@ -214,3 +214,7 @@ locationAnnotation v =
-- See https://github.com/actions/toolkit/issues/193.
escapeNewlines :: Text -> Text
escapeNewlines = replace "\n" "%0A"

-- | Escape special characters which can interfere with the parsing of an annotation.
escapeSpecial :: Text -> Text
escapeSpecial = replace ":" "%3A" . replace "," "%2C" . escapeNewlines

0 comments on commit 6ad9b2d

Please sign in to comment.