diff --git a/build.sh b/build.sh index 09fb26317..e759bdcc2 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,16 @@ #!/bin/bash -e # This script publishes the GraphQL specification document to the web. +# Escape HTML special characters to prevent HTML injection +html_escape() { + local str="$1" + str="${str//&/&}" + str="${str//<}" + str="${str//>/>}" + str="${str//\"/"}" + echo "$str" +} + # Determine if this is a tagged release GITTAG=$(git tag --points-at HEAD) @@ -58,11 +68,12 @@ HTML=" # Include latest draft GITDATE=$(git show -s --format=%cd --date=format:"%a, %b %-d, %Y" HEAD) +GITDATE_ESC=$(html_escape "$GITDATE") HTML="$HTML