Added code to escape forward slashes in metadata values

master
Aadhavan Srinivasan 11 months ago
parent 6701f5389b
commit 506ea63f52

@ -61,7 +61,6 @@ add_date_to_array() {
if test -z "${meta_array[date]}"; then # If there is no existing date in the metadata if test -z "${meta_array[date]}"; then # If there is no existing date in the metadata
meta_array["date"]="$(date -r $1 +'%b %d, %Y')" meta_array["date"]="$(date -r $1 +'%b %d, %Y')"
fi fi
echo "${meta_array[date]}"
} }
add_header_and_footer() { add_header_and_footer() {
@ -103,6 +102,7 @@ add_header_and_footer_to_index() {
replace_vars() { replace_vars() {
# Loop through the keys of the 'meta_array' array, search for all occurences of the key in the HTML doc, and replace them with the corresponding value.. # Loop through the keys of the 'meta_array' array, search for all occurences of the key in the HTML doc, and replace them with the corresponding value..
for arr_key in "${!meta_array[@]}"; do for arr_key in "${!meta_array[@]}"; do
meta_array[$arr_key]=${meta_array[$arr_key]/\//\\/} # Escape all forward slashes in the value
sed -i "s/[\$][\$]$arr_key[\$][\$]/${meta_array[$arr_key]}/g" $1 sed -i "s/[\$][\$]$arr_key[\$][\$]/${meta_array[$arr_key]}/g" $1
done done

Loading…
Cancel
Save