Skip to content

Commit f8fc208

Browse files
authored
Update add-netlify-links.yml
1 parent 7fe1de5 commit f8fc208

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.github/workflows/add-netlify-links.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,22 @@ jobs:
2424
env:
2525
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
2626
run: |
27+
# Function to sanitize file paths
28+
sanitize_file_path() {
29+
local file_path="$1"
30+
# Allow only alphanumeric characters, _ . / and -
31+
if [[ ! "$file_path" =~ ^[a-zA-Z0-9._/-]+$ ]]; then
32+
echo "Invalid file path detected: $file_path" >&2
33+
exit 1
34+
fi
35+
}
36+
2737
new_links=""
2838
base_link='https://deploy-preview-${{ github.event.number }}--mongodb-docs-csharp.netlify.app'
2939
files=$(echo "$CHANGED_FILES" | tr "," "\n")
3040
for file in $files; do
3141
echo "processing ${file}"
42+
sanitize_file_path "$file"
3243
if (! grep -s "includes/" <<< $file) &&
3344
(! grep -s "images/" <<< $file) &&
3445
(! grep -s "examples/" <<< $file); then

0 commit comments

Comments
 (0)