Skip to content

Commit

Permalink
Merge pull request probonopd#70 from itsmattkc/master
Browse files Browse the repository at this point in the history
Fix bug with filenames that have spaces in them
  • Loading branch information
probonopd authored Dec 23, 2020
2 parents 1f1f4e9 + ad170c7 commit 64e9322
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,30 @@ fi

echo "Upload binaries to the release..."

# Need to URL encode the basename, so we have this function to do so
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
[a-zA-Z0-9.~_-]) printf '%s' "$c" ;;
*) printf '%%%02X' "'$c" ;;
esac
done
LC_COLLATE=$old_lc_collate
}

for FILE in "$@" ; do
FULLNAME="${FILE}"
BASENAME="$(basename "${FILE}")"
curl -H "Authorization: token ${GITHUB_TOKEN}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/octet-stream" \
--data-binary @$FULLNAME \
"$upload_url?name=$BASENAME"
--data-binary "@$FULLNAME" \
"$upload_url?name=$(urlencode "$BASENAME")"
echo ""
done

Expand Down

0 comments on commit 64e9322

Please sign in to comment.