[mutter] monitor-config-store: Properly escape monitor spec
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-config-store: Properly escape monitor spec
- Date: Fri, 29 Jan 2021 17:13:28 +0000 (UTC)
commit 70cdd720405699c92abda145e356c84e0b9bad96
Author: Thomas Mühlbacher <tmuehlbacher posteo net>
Date: Wed Jan 27 19:59:26 2021 +0100
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.
To make this change not break any tests, the sample monitor configs need
to be adjusted as well. Apostrophes don't strictly have to be escaped in
XML text elements. However, we now do escape the elements in
`<monitorspec>` specifically.
Closes: <https://gitlab.gnome.org/GNOME/mutter/-/issues/1011>
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1685>
src/backends/meta-monitor-config-store.c | 23 ++++++++++++++++++----
src/tests/migration/oneoff-new-finished.xml | 4 ++--
src/tests/migration/oneoff-new.xml | 4 ++--
src/tests/migration/oneoff-old.xml | 4 ++--
src/tests/migration/rotated-new-finished.xml | 2 +-
src/tests/migration/rotated-new.xml | 2 +-
src/tests/migration/rotated-old.xml | 2 +-
src/tests/migration/wiggle-new-finished.xml | 2 +-
src/tests/migration/wiggle-new.xml | 2 +-
src/tests/migration/wiggle-old.xml | 2 +-
src/tests/monitor-configs/first-rotated.xml | 4 ++--
src/tests/monitor-configs/fractional-scale.xml | 2 +-
.../high-precision-fractional-scale.xml | 2 +-
src/tests/monitor-configs/interlaced.xml | 2 +-
src/tests/monitor-configs/lid-scale.xml | 2 +-
src/tests/monitor-configs/lid-switch.xml | 8 ++++----
src/tests/monitor-configs/mirrored.xml | 4 ++--
.../non-preferred-tiled-custom-resolution.xml | 2 +-
src/tests/monitor-configs/oneoff.xml | 4 ++--
src/tests/monitor-configs/primary.xml | 4 ++--
src/tests/monitor-configs/scale.xml | 2 +-
src/tests/monitor-configs/second-rotated-tiled.xml | 4 ++--
src/tests/monitor-configs/second-rotated.xml | 4 ++--
src/tests/monitor-configs/single.xml | 2 +-
.../monitor-configs/tiled-custom-resolution.xml | 2 +-
src/tests/monitor-configs/tiled.xml | 2 +-
src/tests/monitor-configs/underscanning.xml | 2 +-
src/tests/monitor-configs/vertical.xml | 4 ++--
28 files changed, 59 insertions(+), 44 deletions(-)
---
diff --git a/src/backends/meta-monitor-config-store.c b/src/backends/meta-monitor-config-store.c
index 8d116817d5..4dd357a151 100644
--- a/src/backends/meta-monitor-config-store.c
+++ b/src/backends/meta-monitor-config-store.c
@@ -1138,19 +1138,34 @@ append_monitor_spec (GString *buffer,
MetaMonitorSpec *monitor_spec,
const char *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);
}
diff --git a/src/tests/migration/oneoff-new-finished.xml b/src/tests/migration/oneoff-new-finished.xml
index d3ee95c36f..9e71069de5 100644
--- a/src/tests/migration/oneoff-new-finished.xml
+++ b/src/tests/migration/oneoff-new-finished.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -22,7 +22,7 @@
<disabled>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</monitorspec>
diff --git a/src/tests/migration/oneoff-new.xml b/src/tests/migration/oneoff-new.xml
index 1475c07e2f..02d85f4ded 100644
--- a/src/tests/migration/oneoff-new.xml
+++ b/src/tests/migration/oneoff-new.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -22,7 +22,7 @@
<disabled>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</monitorspec>
diff --git a/src/tests/migration/oneoff-old.xml b/src/tests/migration/oneoff-old.xml
index 185ecd6669..2293791468 100644
--- a/src/tests/migration/oneoff-old.xml
+++ b/src/tests/migration/oneoff-old.xml
@@ -2,7 +2,7 @@
<configuration>
<clone>no</clone>
<output name="DP-1">
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
<width>800</width>
@@ -18,7 +18,7 @@
<underscanning>no</underscanning>
</output>
<output name="DP-2">
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</output>
diff --git a/src/tests/migration/rotated-new-finished.xml b/src/tests/migration/rotated-new-finished.xml
index ad8d614eb2..a67c376dc5 100644
--- a/src/tests/migration/rotated-new-finished.xml
+++ b/src/tests/migration/rotated-new-finished.xml
@@ -12,7 +12,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/migration/rotated-new.xml b/src/tests/migration/rotated-new.xml
index f8de70beb1..f419645462 100644
--- a/src/tests/migration/rotated-new.xml
+++ b/src/tests/migration/rotated-new.xml
@@ -12,7 +12,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/migration/rotated-old.xml b/src/tests/migration/rotated-old.xml
index cf48ef7b9d..d252f01176 100644
--- a/src/tests/migration/rotated-old.xml
+++ b/src/tests/migration/rotated-old.xml
@@ -2,7 +2,7 @@
<configuration>
<clone>no</clone>
<output name="DP-1">
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
<width>600</width>
diff --git a/src/tests/migration/wiggle-new-finished.xml b/src/tests/migration/wiggle-new-finished.xml
index 4d7e9dca11..c4a56556f9 100644
--- a/src/tests/migration/wiggle-new-finished.xml
+++ b/src/tests/migration/wiggle-new-finished.xml
@@ -12,7 +12,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/migration/wiggle-new.xml b/src/tests/migration/wiggle-new.xml
index 9afc904964..cd1acf7176 100644
--- a/src/tests/migration/wiggle-new.xml
+++ b/src/tests/migration/wiggle-new.xml
@@ -12,7 +12,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/migration/wiggle-old.xml b/src/tests/migration/wiggle-old.xml
index be57011de2..b0c996c035 100644
--- a/src/tests/migration/wiggle-old.xml
+++ b/src/tests/migration/wiggle-old.xml
@@ -2,7 +2,7 @@
<configuration>
<clone>no</clone>
<output name="DP-1">
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
<width>600</width>
diff --git a/src/tests/monitor-configs/first-rotated.xml b/src/tests/monitor-configs/first-rotated.xml
index f247975546..59a42bef5b 100644
--- a/src/tests/monitor-configs/first-rotated.xml
+++ b/src/tests/monitor-configs/first-rotated.xml
@@ -11,7 +11,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -32,7 +32,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/fractional-scale.xml b/src/tests/monitor-configs/fractional-scale.xml
index eeb49b6bcd..991a47d14a 100644
--- a/src/tests/monitor-configs/fractional-scale.xml
+++ b/src/tests/monitor-configs/fractional-scale.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/high-precision-fractional-scale.xml
b/src/tests/monitor-configs/high-precision-fractional-scale.xml
index 8fe66477da..2a0d439128 100644
--- a/src/tests/monitor-configs/high-precision-fractional-scale.xml
+++ b/src/tests/monitor-configs/high-precision-fractional-scale.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/interlaced.xml b/src/tests/monitor-configs/interlaced.xml
index e7e22feb46..b02f1cf946 100644
--- a/src/tests/monitor-configs/interlaced.xml
+++ b/src/tests/monitor-configs/interlaced.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/lid-scale.xml b/src/tests/monitor-configs/lid-scale.xml
index 9b40f0f9ac..d5bfecb110 100644
--- a/src/tests/monitor-configs/lid-scale.xml
+++ b/src/tests/monitor-configs/lid-scale.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>eDP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/lid-switch.xml b/src/tests/monitor-configs/lid-switch.xml
index fe51446602..1d43c98bdd 100644
--- a/src/tests/monitor-configs/lid-switch.xml
+++ b/src/tests/monitor-configs/lid-switch.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>eDP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -28,7 +28,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -52,7 +52,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -76,7 +76,7 @@
<monitor>
<monitorspec>
<connector>eDP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/mirrored.xml b/src/tests/monitor-configs/mirrored.xml
index 0db260f8c5..7866b4aae6 100644
--- a/src/tests/monitor-configs/mirrored.xml
+++ b/src/tests/monitor-configs/mirrored.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -20,7 +20,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml
b/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml
index 8ee2abf09e..5f46583eba 100644
--- a/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml
+++ b/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/oneoff.xml b/src/tests/monitor-configs/oneoff.xml
index 4e5c6b7a59..63e641cf01 100644
--- a/src/tests/monitor-configs/oneoff.xml
+++ b/src/tests/monitor-configs/oneoff.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -22,7 +22,7 @@
<disabled>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x654321</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/primary.xml b/src/tests/monitor-configs/primary.xml
index 7238b4fd8a..ce78b1099d 100644
--- a/src/tests/monitor-configs/primary.xml
+++ b/src/tests/monitor-configs/primary.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -25,7 +25,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/scale.xml b/src/tests/monitor-configs/scale.xml
index d6c66b70bb..c011900efb 100644
--- a/src/tests/monitor-configs/scale.xml
+++ b/src/tests/monitor-configs/scale.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/second-rotated-tiled.xml
b/src/tests/monitor-configs/second-rotated-tiled.xml
index a8593d5038..14ba91b4e6 100644
--- a/src/tests/monitor-configs/second-rotated-tiled.xml
+++ b/src/tests/monitor-configs/second-rotated-tiled.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -28,7 +28,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/second-rotated.xml b/src/tests/monitor-configs/second-rotated.xml
index ee70c5e9b1..885b2bf830 100644
--- a/src/tests/monitor-configs/second-rotated.xml
+++ b/src/tests/monitor-configs/second-rotated.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -28,7 +28,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/single.xml b/src/tests/monitor-configs/single.xml
index 771957a4ac..cc01b4a63e 100644
--- a/src/tests/monitor-configs/single.xml
+++ b/src/tests/monitor-configs/single.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/tiled-custom-resolution.xml
b/src/tests/monitor-configs/tiled-custom-resolution.xml
index b51c3b6f6e..85939dd1f7 100644
--- a/src/tests/monitor-configs/tiled-custom-resolution.xml
+++ b/src/tests/monitor-configs/tiled-custom-resolution.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/tiled.xml b/src/tests/monitor-configs/tiled.xml
index 806a5853bd..0ed149ffc5 100644
--- a/src/tests/monitor-configs/tiled.xml
+++ b/src/tests/monitor-configs/tiled.xml
@@ -8,7 +8,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/underscanning.xml b/src/tests/monitor-configs/underscanning.xml
index 7bcd6e75a2..3ab02476d6 100644
--- a/src/tests/monitor-configs/underscanning.xml
+++ b/src/tests/monitor-configs/underscanning.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
diff --git a/src/tests/monitor-configs/vertical.xml b/src/tests/monitor-configs/vertical.xml
index 76f11297bf..0546b055cc 100644
--- a/src/tests/monitor-configs/vertical.xml
+++ b/src/tests/monitor-configs/vertical.xml
@@ -7,7 +7,7 @@
<monitor>
<monitorspec>
<connector>DP-1</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
@@ -24,7 +24,7 @@
<monitor>
<monitorspec>
<connector>DP-2</connector>
- <vendor>MetaProduct's Inc.</vendor>
+ <vendor>MetaProduct's Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]