From 4d391d23548fc92871cc1a792eb4cafb74e0c35d Mon Sep 17 00:00:00 2001 From: Benjamin Sonntag Date: Fri, 7 Oct 2011 14:07:03 +0000 Subject: [PATCH] fix 2 bugs : didn't allow %% in folder names, and fix issue when using & in redirect urls --- src/functions_hosting.sh | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/functions_hosting.sh b/src/functions_hosting.sh index 31cf438f..97426e3d 100644 --- a/src/functions_hosting.sh +++ b/src/functions_hosting.sh @@ -83,18 +83,25 @@ host_create() { local TMP_FILE=$(mktemp "/tmp/alternc_host.XXXXXX") cp "$TEMPLATE" "$TMP_FILE" + # Substitute special characters : + FQDN2="`echo $FQDN | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" + DOCUMENT_ROOT2="`echo $DOCUMENT_ROOT | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" + ACCOUNT_ROOT2="`echo $ACCOUNT_ROOT | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" + REDIRECT2="`echo $REDIRECT | sed -e 's/\\\\/\\\\\\\\/g' -e 's/#/\\\\#/g' -e 's/&/\\\\\\&/g'`" + # Put the good value in the conf file sed -i \ - -e "s#%%fqdn%%#$FQDN#g" \ - -e "s#%%document_root%%#$DOCUMENT_ROOT#g" \ - -e "s#%%account_root%%#$ACCOUNT_ROOT#g" \ - -e "s#%%redirect%%#$REDIRECT#g" \ + -e "s#%%fqdn%%#$FQDN2#g" \ + -e "s#%%document_root%%#$DOCUMENT_ROOT2#g" \ + -e "s#%%account_root%%#$ACCOUNT_ROOT2#g" \ + -e "s#%%redirect%%#$REDIRECT2#g" \ $TMP_FILE # Check if all is right in the conf file # If not, put a debug message - local ISNOTGOOD=$(grep "%%" "$TMP_FILE") - [ "$ISNOTGOOD" ] && (echo "# There was a probleme in the generation : $ISNOTGOOD" > "$TMP_FILE" ; return 44 ) +# NO : redirect and document_root COULD contains legitimate %% expressions (...) +# local ISNOTGOOD=$(grep "%%" "$TMP_FILE") +# [ "$ISNOTGOOD" ] && (echo "# There was a probleme in the generation : $ISNOTGOOD" > "$TMP_FILE" ; return 44 ) # Put the conf file in prod mkdir -p "$(dirname "$FILE_TARGET")"