Skip to content

What is the correct character escaping for workflow command values e.g. echo ::error::XXXX #26736

Answered by ghost
ben-spiller asked this question in Actions
Discussion options

You must be logged in to vote

Hi, sorry for the delay.

The actions/toolkit has a way to sanitize an input into a string – could you give these commands a try?

github.com

actions/toolkit/blob/cee7d92d1d02e3107c9b1387b9690b89096b67be/packages/core/src/command.ts#L92-L105

  1. function escapeData(s: any): string {
  2. return toCommandValue(s)
  3. .replace(/%/g, '%25')
  4. .replace(/\r/g, '%0D')
  5. .replace(/\n/g, '%0A')
  6. }
  7. function escapeProperty(s: any): string {
  8. return toCommandValue(s)
  9. .replace(/%/g, '%25')
  10. .replace(/\r/g, '%0D')
  11. .replace(/\n/g, '%0A')
  12. .replace(/:/g, '%3A')
  13. .replace(/,/g, '%2C')

Replies: 12 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Actions Build, test, and automate your deployment pipeline with world-class CI/CD Product Feedback
4 participants