[GH-ISSUE #403] step set output string should be unescaped #285

Closed
opened 2026-03-01 21:42:03 +03:00 by kerem · 1 comment
Owner

Originally created by @theowenyoung on GitHub (Oct 30, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/403

Hi, I found act does not unescape the step outputs string, for example:

This workflow will be printed Hello 2%25 in act
It will be printed Hello 2% in Github Actions

on:
  workflow_dispatch:
  push:
jobs:
  script:
    name: Print
    runs-on: ubuntu-latest
    steps:
      - name: Format message
        id: format
        uses: actions/github-script@v2
        with:
          script: |
            return {"message":"Hello 2%"}
      - name: Format message
        uses: actions/github-script@v2
        env:
          TEXT: ${{ fromJSON(steps.format.outputs.result).message }}
        with:
          script: |
            console.log('text', process.env.TEXT)
            // will be printed Hello 2%25 in act
            // will be printed Hello 2% in Github Actions

Github demo action log: https://github.com/theowenyoung/test-actions/runs/1331351240?check_suite_focus=true

Originally created by @theowenyoung on GitHub (Oct 30, 2020). Original GitHub issue: https://github.com/nektos/act/issues/403 Hi, I found act does not unescape the step outputs string, for example: > This workflow will be printed Hello 2%25 in act > It will be printed Hello 2% in Github Actions ```yaml on: workflow_dispatch: push: jobs: script: name: Print runs-on: ubuntu-latest steps: - name: Format message id: format uses: actions/github-script@v2 with: script: | return {"message":"Hello 2%"} - name: Format message uses: actions/github-script@v2 env: TEXT: ${{ fromJSON(steps.format.outputs.result).message }} with: script: | console.log('text', process.env.TEXT) // will be printed Hello 2%25 in act // will be printed Hello 2% in Github Actions ``` Github demo action log: https://github.com/theowenyoung/test-actions/runs/1331351240?check_suite_focus=true
kerem closed this issue 2026-03-01 21:42:04 +03:00
Author
Owner

@theowenyoung commented on GitHub (Oct 30, 2020):

From github toolkit core, github.com/actions/toolkit@0759cdc230/packages/core/src/command.ts (L53-L94)

function escapeData(s: any): string { 
   return toCommandValue(s) 
     .replace(/%/g, '%25') 
     .replace(/\r/g, '%0D') 
     .replace(/\n/g, '%0A') 
 } 

I supposed github escaped the command string, so, maybe we should unescape the string?

<!-- gh-comment-id:719823020 --> @theowenyoung commented on GitHub (Oct 30, 2020): From github toolkit core, https://github.com/actions/toolkit/blob/0759cdc2309acfd91b6503597dcfa02a3cee99d0/packages/core/src/command.ts#L53-L94 ```javascript function escapeData(s: any): string { return toCommandValue(s) .replace(/%/g, '%25') .replace(/\r/g, '%0D') .replace(/\n/g, '%0A') } ``` I supposed github escaped the command string, so, maybe we should unescape the string?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#285
No description provided.