From b29ee6653bb9f1bda8230e93b489638f8fcbdebd Mon Sep 17 00:00:00 2001 From: Jared Vititoe Date: Thu, 1 Jan 2026 16:52:35 -0500 Subject: [PATCH] Fix .env file parsing to properly handle quoted values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Updated parse_ini_file to use INI_SCANNER_TYPED - Added quote stripping for all .env value parsing - Fixes database connection and Discord webhook issues when values are quoted 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- config/config.php | 14 +++++++++++++- create_ticket_api.php | 12 +++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/config/config.php b/config/config.php index f5c7898..997a82d 100644 --- a/config/config.php +++ b/config/config.php @@ -1,7 +1,19 @@ $value) { + if (is_string($value)) { + if ((substr($value, 0, 1) === '"' && substr($value, -1) === '"') || + (substr($value, 0, 1) === "'" && substr($value, -1) === "'")) { + $envVars[$key] = substr($value, 1, -1); + } + } + } +} // Global configuration $GLOBALS['config'] = [ diff --git a/create_ticket_api.php b/create_ticket_api.php index 4684974..2e7bc87 100644 --- a/create_ticket_api.php +++ b/create_ticket_api.php @@ -15,7 +15,7 @@ if (!file_exists($envFile)) { exit; } -$envVars = parse_ini_file($envFile); +$envVars = parse_ini_file($envFile, false, INI_SCANNER_TYPED); if (!$envVars) { echo json_encode([ 'success' => false, @@ -24,6 +24,16 @@ if (!$envVars) { exit; } +// Strip quotes from values if present (parse_ini_file may include them) +foreach ($envVars as $key => $value) { + if (is_string($value)) { + if ((substr($value, 0, 1) === '"' && substr($value, -1) === '"') || + (substr($value, 0, 1) === "'" && substr($value, -1) === "'")) { + $envVars[$key] = substr($value, 1, -1); + } + } +} + // Database connection with detailed error handling $conn = new mysqli( $envVars['DB_HOST'],