Don't stop additional components in UDS

This commit is contained in:
selfhoster1312 2024-08-05 17:46:26 +02:00 committed by selfhoster1312
parent 78952a2db0
commit 82419e03bf

View file

@ -11,17 +11,17 @@ rp_validate_proxy_path() {
url_regex='^(http://(127\.[0-9]+\.[0-9]+\.[0-9]+|localhost)|https://.*)(:[0-9]+)?(/.*)?$' url_regex='^(http://(127\.[0-9]+\.[0-9]+\.[0-9]+|localhost)|https://.*)(:[0-9]+)?(/.*)?$'
[[ ! "$proxy_path" =~ $url_regex ]] && ynh_die \ [[ ! "$proxy_path" =~ $url_regex ]] && ynh_die \
"For secure reason, you can't use an unencrypted http remote destination couple with ssowat for your reverse proxy: $proxy_path" 1 "For secure reason, you can't use an unencrypted http remote destination couple with ssowat for your reverse proxy: $proxy_path" 1
fi
# Don't allow trailing slash or additional URI components in proxy_path # Don't allow trailing slash or additional URI components in proxy_path if not unix domain socket
if [[ "$proxy_path" =~ ^https?:// ]]; then if [[ "$proxy_path" =~ ^https?:// ]]; then
res="${proxy_path//[^\/]}" res="${proxy_path//[^\/]}"
if [[ "${#res}" != "2" ]]; then if [[ "${#res}" != "2" ]]; then
if [[ "${#res}" = "3" ]] && [[ "$proxy_path" =~ /$ ]]; then if [[ "${#res}" = "3" ]] && [[ "$proxy_path" =~ /$ ]]; then
# If it's only one trailing slash (no more components), just remove it # If it's only one trailing slash (no more components), just remove it
proxy_path="${proxy_path::-1}" proxy_path="${proxy_path::-1}"
else else
ynh_die "Reverse proxy URL cannot contain additional slashes or components: $proxy_path" 1 ynh_die "Reverse proxy URL cannot contain additional slashes or components: $proxy_path" 1
fi
fi fi
fi fi
fi fi