[d-feet: 1/2] Escape markup in property values




commit 9215f2b196529a24e7b4920a25a8a9fa9a41941d
Author: James Westman <james flyingpimonster net>
Date:   Mon Aug 17 17:11:29 2020 -0500

    Escape markup in property values
    
    This fixes an issue where property values that contained markup characters
    weren't displayed.
    
    Fixes #8.

 src/dfeet/introspection_helper.py | 4 ++--
 src/tests/tests.py.in             | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/src/dfeet/introspection_helper.py b/src/dfeet/introspection_helper.py
index 74789f5..13dfee6 100644
--- a/src/dfeet/introspection_helper.py
+++ b/src/dfeet/introspection_helper.py
@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 
-from gi.repository import GObject, Gio
+from gi.repository import GLib, GObject, Gio
 from dfeet import dbus_utils
 
 
@@ -87,7 +87,7 @@ class DBusProperty(DBusInterface):
             args_signature_markup(sig),
             args_name_markup(self.property_info.name), " / ".join(readwrite))
         if self.value is not None:
-            s += " = %s" % (self.value,)
+            s += " = %s" % (GLib.markup_escape_text(str(self.value), -1),)
         return s
 
     @property
diff --git a/src/tests/tests.py.in b/src/tests/tests.py.in
index de40cf3..d508baf 100755
--- a/src/tests/tests.py.in
+++ b/src/tests/tests.py.in
@@ -74,7 +74,7 @@ class IntrospectionHelperTest(unittest.TestCase):
         # get the markup string with value for struct prop (see bgo #702593)
         obj_prop = DBusProperty(obj_iface, obj_iface.iface_info.properties[2])
         obj_prop.value = ("string", 1, 2)
-        self.assertIn("'string', 1, 2", obj_prop.markup_str)
+        self.assertIn("&apos;string&apos;, 1, 2", obj_prop.markup_str)
 
     def test_dbus_signal(self):
         """test DBusSignal class"""


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