Skip to content

Commit

Permalink
fix: update safe output regex and the docs (#1805)
Browse files Browse the repository at this point in the history
Co-authored-by: jackton1 <jackton1@users.noreply.github.com>
Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: Tonye Jack <jtonye@ymail.com>
  • Loading branch information
4 people authored Dec 23, 2023
1 parent 0102c07 commit ff2f6e6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 16 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,12 @@ Support this project with a :star:
# Default: "\n"
recover_files_separator: ''

# Apply sanitization to output filenames before being set as
# output.
# Type: boolean
# Default: "true"
safe_output: ''

# Split character for output strings.
# Type: string
# Default: " "
Expand Down
47 changes: 33 additions & 14 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,10 @@ export const setOutput = async ({

// if safeOutput is true, escape special characters for bash shell
if (safeOutput) {
cleanedValue = cleanedValue.replace(/[$()`|&;]/g, '\\$&')
cleanedValue = cleanedValue.replace(
/[^\x20-\x7E]|[:*?"<>|;`$()&!]/g,
'\\$&'
)
}

core.setOutput(key, cleanedValue)
Expand Down

0 comments on commit ff2f6e6

Please sign in to comment.