Compare commits
1 Commits
fix/report
...
b4fcba7cca
| Author | SHA1 | Date | |
|---|---|---|---|
| b4fcba7cca |
@@ -82,13 +82,7 @@ def status_phrase(status):
|
|||||||
key = DEFAULT_STATUS
|
key = DEFAULT_STATUS
|
||||||
if key in STATUS_PHRASES:
|
if key in STATUS_PHRASES:
|
||||||
return STATUS_PHRASES[key]
|
return STATUS_PHRASES[key]
|
||||||
# Backticks removed, not escaped: the verbatim value goes inside a code
|
return "finished with status `" + status.strip() + "`"
|
||||||
# span in a **bold** header, and a backtick in it closes the span early --
|
|
||||||
# the rest of the status then renders as markdown. Nothing hostile is
|
|
||||||
# expected here (`${{ job.status }}` is written by whoever wrote the
|
|
||||||
# workflow), but this repo is public and consumed by four others, and a
|
|
||||||
# branch name or matrix value could reach this argument later.
|
|
||||||
return "finished with status `" + status.strip().replace("`", "") + "`"
|
|
||||||
|
|
||||||
|
|
||||||
def missing_log_note(path, phrase):
|
def missing_log_note(path, phrase):
|
||||||
|
|||||||
9
test_report_job_log.py
Executable file → Normal file
9
test_report_job_log.py
Executable file → Normal file
@@ -313,15 +313,6 @@ class TestStatusPhrase(unittest.TestCase):
|
|||||||
self.assertEqual(report_job_log.status_phrase("weird"),
|
self.assertEqual(report_job_log.status_phrase("weird"),
|
||||||
"finished with status `weird`")
|
"finished with status `weird`")
|
||||||
|
|
||||||
def test_a_backtick_in_an_unknown_status_cannot_escape_the_code_span(self):
|
|
||||||
"""The verbatim value sits in a code span inside a **bold** header, so
|
|
||||||
a backtick in it would close the span and let the rest render as
|
|
||||||
markdown. `${{ job.status }}` is workflow-author-controlled rather than
|
|
||||||
hostile, but this script is public and shared by four repos."""
|
|
||||||
phrase = report_job_log.status_phrase("x` **loud** `y")
|
|
||||||
self.assertEqual(phrase, "finished with status `x **loud** y`")
|
|
||||||
self.assertEqual(phrase.count("`"), 2)
|
|
||||||
|
|
||||||
def test_default_constant_is_failed(self):
|
def test_default_constant_is_failed(self):
|
||||||
"""Named so that changing it is a deliberate act, not a typo."""
|
"""Named so that changing it is a deliberate act, not a typo."""
|
||||||
self.assertEqual(report_job_log.DEFAULT_STATUS, "failed")
|
self.assertEqual(report_job_log.DEFAULT_STATUS, "failed")
|
||||||
|
|||||||
Reference in New Issue
Block a user