From df3f6de16f31affd35fb63d3f9bcfd682a920f13 Mon Sep 17 00:00:00 2001
From: Boris Yumankulov <boria138@altlinux.org>
Date: Mon, 13 Jan 2025 00:41:22 +0500
Subject: [PATCH] edit_db_from_gui: impove windows paths escaping closed #217

---
 data_from_portwine/scripts/functions_helper | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/data_from_portwine/scripts/functions_helper b/data_from_portwine/scripts/functions_helper
index f7d31fcd..8fcccb4b 100755
--- a/data_from_portwine/scripts/functions_helper
+++ b/data_from_portwine/scripts/functions_helper
@@ -2891,6 +2891,10 @@ edit_db_from_gui () {
             elif [[ $proxy_mod_db =~ (${translations[Enabled]}|${translations[Enable]}) ]] ; then
                 proxy_mod_db=enabled
             fi
+
+            # Escaping backslashes and quotes for Windows paths
+            proxy_mod_db=$(echo "$proxy_mod_db" | sed 's/\\/\\\\\\\\/g; s/"/\\"/g')
+
             if [[ $(<"${PORTWINE_DB_FILE}") =~ export\ ${mod_db}= ]]
             then sed -i "s|export ${mod_db}=.*|export ${mod_db}=\"$proxy_mod_db\"|g" "${PORTWINE_DB_FILE}"
             else echo "export ${mod_db}=\"$proxy_mod_db\"" >> "${PORTWINE_DB_FILE}"