From 157c8ebd3350ab9da7971e5d394b55abf5ac3bb1 Mon Sep 17 00:00:00 2001 From: maxpozdeev Date: Thu, 6 Oct 2022 00:47:31 +0300 Subject: [PATCH] - use single quotes in config.php to avoid possible malformed strings (fixes GH-40) --- src/includes/class.config.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/includes/class.config.php b/src/includes/class.config.php index 5e259e3..4159542 100644 --- a/src/includes/class.config.php +++ b/src/includes/class.config.php @@ -300,14 +300,14 @@ class Config if (!preg_match("/^[a-zA-Z0-9_]+$/", $key)) { throw new Exception("Unexpected constant name: ". $key); } - if (preg_match('~\R~', $value)) { + if (preg_match('~\R~', $value)) { # newlines throw new Exception("Unexpected constant value: ". $value); } - return "define(\"$key\", \"". str_replace( - array("\\", "'", "\""), - array("\\\\", "\\'", "\\\""), - $value ) - . "\");"; + return "define('$key', '". str_replace( + array("\\", "'" ), + array("\\\\", "\\'"), + $value + ) . "');"; } public static function saveDbConfig()