[gnome-flashback] monitor-config-store: properly escape monitor spec



commit ba36de469ae48be1f5fb62565225daeb5614b5c5
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Sun Jan 31 15:33:13 2021 +0200

    monitor-config-store: properly escape monitor spec
    
    Makes sure that monitor specs which may be read from EDID data do not
    contain characters that are invalid in XML. Makes it possible to restore
    monitor configs of monitor models with characters such as '&' in them.
    
    Based on mutter commit:
    https://gitlab.gnome.org/GNOME/mutter/-/commit/70cdd720405699c92a

 backends/gf-monitor-config-store.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/backends/gf-monitor-config-store.c b/backends/gf-monitor-config-store.c
index aa3fd8a..e07af59 100644
--- a/backends/gf-monitor-config-store.c
+++ b/backends/gf-monitor-config-store.c
@@ -1236,19 +1236,34 @@ append_monitor_spec (GString       *buffer,
                      GfMonitorSpec *monitor_spec,
                      const gchar   *indentation)
 {
+  char *escaped;
+
   g_string_append_printf (buffer, "%s<monitorspec>\n", indentation);
+
+  escaped = g_markup_escape_text (monitor_spec->connector, -1);
   g_string_append_printf (buffer, "%s  <connector>%s</connector>\n",
                           indentation,
-                          monitor_spec->connector);
+                          escaped);
+  g_free (escaped);
+
+  escaped = g_markup_escape_text (monitor_spec->vendor, -1);
   g_string_append_printf (buffer, "%s  <vendor>%s</vendor>\n",
                           indentation,
-                          monitor_spec->vendor);
+                          escaped);
+  g_free (escaped);
+
+  escaped = g_markup_escape_text (monitor_spec->product, -1);
   g_string_append_printf (buffer, "%s  <product>%s</product>\n",
                           indentation,
-                          monitor_spec->product);
+                          escaped);
+  g_free (escaped);
+
+  escaped = g_markup_escape_text (monitor_spec->serial, -1);
   g_string_append_printf (buffer, "%s  <serial>%s</serial>\n",
                           indentation,
-                          monitor_spec->serial);
+                          escaped);
+  g_free (escaped);
+
   g_string_append_printf (buffer, "%s</monitorspec>\n", indentation);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]