Skip to content

Commit 6ad9b2d

Browse files
committed
URL-encode "," and ":" characters, which could confuse annotation parsing.
1 parent bbdc00d commit 6ad9b2d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/SpecialOutput.hs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ toAnnotation v = do
113113
title' <- title
114114
let annotation =
115115
mconcat
116-
[ "::" <> level' <> " ",
116+
[ "::" <> escapeSpecial level' <> " ",
117117
location,
118-
"title=" <> title' <> "::",
119-
message'
118+
"title=" <> escapeSpecial title' <> "::",
119+
escapeNewlines message'
120120
]
121121
return $ escapeNewlines annotation <> "\n"
122122
where
@@ -153,7 +153,7 @@ locationAnnotation v =
153153
]
154154
where
155155
fileAnnotation
156-
| (Just s) <- filename = "file=" <> s <> ", "
156+
| (Just s) <- filename = "file=" <> escapeSpecial s <> ", "
157157
| otherwise = ""
158158

159159
colAnnotation
@@ -214,3 +214,7 @@ locationAnnotation v =
214214
-- See https://github.com/actions/toolkit/issues/193.
215215
escapeNewlines :: Text -> Text
216216
escapeNewlines = replace "\n" "%0A"
217+
218+
-- | Escape special characters which can interfere with the parsing of an annotation.
219+
escapeSpecial :: Text -> Text
220+
escapeSpecial = replace ":" "%3A" . replace "," "%2C" . escapeNewlines

0 commit comments

Comments
 (0)