From db903b2750a0ff043b854e8c2e72d93dd9b0d2f8 Mon Sep 17 00:00:00 2001 From: wkrp Date: Wed, 16 Aug 2023 21:23:01 -0400 Subject: [PATCH 1/3] Sanitize env vars when checking for http proxy variables. --- lib/tailwind.ex | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/tailwind.ex b/lib/tailwind.ex index 48c4ee8..1b16db4 100644 --- a/lib/tailwind.ex +++ b/lib/tailwind.ex @@ -319,11 +319,24 @@ defmodule Tailwind do end defp proxy_for_scheme("http") do - System.get_env("HTTP_PROXY") || System.get_env("http_proxy") + get_and_sanitize_env_var("HTTP_PROXY") || get_and_sanitize_env_var("http_proxy") end defp proxy_for_scheme("https") do - System.get_env("HTTPS_PROXY") || System.get_env("https_proxy") + get_and_sanitize_env_var("HTTPS_PROXY") || get_and_sanitize_env_var("https_proxy") + end + + def get_and_sanitize_env_var(env_var) do + trimmed = + case System.get_env(env_var) do + nil -> nil + x -> String.trim(x) + end + + case trimmed do + "" -> nil + _ -> trimmed + end end defp maybe_add_proxy_auth(http_options, scheme) do From 61651bb0377fc763cac34cc5bbb1ee8e68dae1e0 Mon Sep 17 00:00:00 2001 From: wkrp Date: Wed, 16 Aug 2023 21:44:28 -0400 Subject: [PATCH 2/3] Make function private --- lib/tailwind.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tailwind.ex b/lib/tailwind.ex index 1b16db4..45577cc 100644 --- a/lib/tailwind.ex +++ b/lib/tailwind.ex @@ -326,7 +326,7 @@ defmodule Tailwind do get_and_sanitize_env_var("HTTPS_PROXY") || get_and_sanitize_env_var("https_proxy") end - def get_and_sanitize_env_var(env_var) do + defp get_and_sanitize_env_var(env_var) do trimmed = case System.get_env(env_var) do nil -> nil From 32c09564c1cb3cc670c383804876fda6664d6f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Tue, 9 Sep 2025 16:05:22 +0200 Subject: [PATCH 3/3] Update lib/tailwind.ex --- lib/tailwind.ex | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/tailwind.ex b/lib/tailwind.ex index 45577cc..b966e09 100644 --- a/lib/tailwind.ex +++ b/lib/tailwind.ex @@ -327,15 +327,9 @@ defmodule Tailwind do end defp get_and_sanitize_env_var(env_var) do - trimmed = - case System.get_env(env_var) do - nil -> nil - x -> String.trim(x) - end - - case trimmed do + case String.trim(System.get_env(env_var, "")) do "" -> nil - _ -> trimmed + trimmed -> trimmed end end