Skip to content

Commit d907997

Browse files
committed
parallel-make-check: percent-encode warn() workflow-command data
A config name comes from JSON and is only checked for emptiness and a '/', so it can carry %, CR or LF. Passed straight into the ::warning:: workflow command those would truncate the annotation or be parsed as a second command, so escape them in the GitHub branch of warn() per GitHub's documented command-data encoding (% first). Local output is unchanged.
1 parent 7b2d19c commit d907997

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.github/scripts/parallel-make-check.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,14 @@ def dump(title: str, path: Path) -> None:
247247
def warn(msg: str) -> None:
248248
# GitHub surfaces ::warning:: as an annotation at the top of the run;
249249
# locally it is just a line. Informational only - never fails the run.
250-
print(f"::warning::{msg}" if ON_GITHUB else f"WARNING: {msg}")
250+
if ON_GITHUB:
251+
# Percent-encode the command data (GitHub's documented escaping) so
252+
# a stray %, CR or LF - e.g. from a config name out of the JSON -
253+
# can't truncate the annotation or be read as a second command.
254+
msg = msg.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A")
255+
print(f"::warning::{msg}")
256+
else:
257+
print(f"WARNING: {msg}")
251258

252259

253260
def stale_estimate(cfg: Config, minutes: float) -> bool:

0 commit comments

Comments
 (0)