From b82fe695cce4247fb5ea939deec486e9593137d4 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Thu, 20 Feb 2025 02:50:25 +0100 Subject: [PATCH] URI encode --- immich/rootfs/etc/cont-init.d/99-run.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/immich/rootfs/etc/cont-init.d/99-run.sh b/immich/rootfs/etc/cont-init.d/99-run.sh index 5551a652f..194926a4f 100755 --- a/immich/rootfs/etc/cont-init.d/99-run.sh +++ b/immich/rootfs/etc/cont-init.d/99-run.sh @@ -166,11 +166,31 @@ check_vector_extension() { fi } +url_encode() { + local string="${1}" + local length="${#string}" + local encoded="" + for (( i = 0; i < length; i++ )); do + local c="${string:i:1}" + case $c in + [a-zA-Z0-9.~_-]) + encoded+="$c" + ;; + *) + printf -v hex '%%%02X' "'$c" + encoded+="${hex}" + ;; + esac + done + echo "${encoded}" +} + ######################### # Main script execution # ######################### export_options +DB_PASSWORD="$(url_encode "${DB_PASSWORD}")" check_db_hostname migrate_database validate_config