summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2018-10-04 17:32:17 +0200
committerChristoph Reiter <reiter.christoph@gmail.com>2018-11-04 16:48:28 +0100
commit8c1a54efd7e2df72713e55ac9de32dad62c1003d (patch)
tree9c14067a174c9f96a4894de582283d752471ba5b /tests
parent2de406218ba5d57baec6dc9bfa95d10bf93af06d (diff)
downloadpygobject-8c1a54efd7e2df72713e55ac9de32dad62c1003d.tar.gz
overrides: Fix length parameter when passing non-ascii strings to Gtk.Builder.add_from_string/add_objects_from_string
It was passing the codepoint count instead of the length in bytes which lead to things reading past the provided memory and crashes. Also use the same code for Gtk.UIManager.add_ui_from_string() Fixes #255
Diffstat (limited to 'tests')
-rw-r--r--tests/test_overrides_gtk.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py
index 1e365525..c515e513 100644
--- a/tests/test_overrides_gtk.py
+++ b/tests/test_overrides_gtk.py
@@ -822,6 +822,30 @@ class TestBuilder(unittest.TestCase):
[]),
}
+ def test_add_from_string(self):
+ builder = Gtk.Builder()
+ builder.add_from_string(u"")
+ builder.add_from_string("")
+
+ def get_example(string):
+ return u"""\
+<interface>
+ <menu id="appmenu">
+ <section>
+ <item>
+ <attribute name="label">%s</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>""" % string
+
+ builder.add_from_string(get_example(u"ä" * 1000))
+
+ builder = Gtk.Builder()
+ builder.add_objects_from_string(u"", [''])
+ builder.add_objects_from_string("", [''])
+ builder.add_objects_from_string(get_example(u"ä" * 1000), [''])
+
def test_extract_handler_and_args_object(self):
class Obj():
pass