From 20fe4bfb03b00edd9bc8cd9ee7bd546e236cf001 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marta=20Marczykowska-G=C3=B3recka?= Date: Thu, 13 Aug 2020 19:16:52 +0200 Subject: [PATCH] Fixed grey label color value causing accidental green icons fixes QubesOS/qubes-issues#3471 --- qubes/app.py | 7 ++++++- qubes/tests/app.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/qubes/app.py b/qubes/app.py index d2197fb5d..9afacecf4 100644 --- a/qubes/app.py +++ b/qubes/app.py @@ -981,6 +981,11 @@ def _migrate_global_properties(self): pass node_default_fw_netvm.getparent().remove(node_default_fw_netvm) + # fix grey being green + grey_label = self.xml.find('./labels/label[@color=\'0x555753\']') + if grey_label: + grey_label.set('color', '0x555555') + def load(self, lock=False): """Open qubes.xml @@ -1211,7 +1216,7 @@ def load_initial_values(self): 2: qubes.Label(2, '0xf57900', 'orange'), 3: qubes.Label(3, '0xedd400', 'yellow'), 4: qubes.Label(4, '0x73d216', 'green'), - 5: qubes.Label(5, '0x555753', 'gray'), + 5: qubes.Label(5, '0x555555', 'gray'), 6: qubes.Label(6, '0x3465a4', 'blue'), 7: qubes.Label(7, '0x75507b', 'purple'), 8: qubes.Label(8, '0x000000', 'black'), diff --git a/qubes/tests/app.py b/qubes/tests/app.py index a9c47ce09..5463eb946 100644 --- a/qubes/tests/app.py +++ b/qubes/tests/app.py @@ -508,6 +508,49 @@ def test_100_property_migrate_default_fw_netvm(self): self.app.close() del self.app + def test_101_property_migrate_label(self): + xml_template = """ + + + + + + + + + + + 1 + sys-net + True + + + 2fcfc1f4-b2fe-4361-931a-c5294b35edfa + + + + + + + """ + with self.subTest('replace_label'): + with open('/tmp/qubestest.xml', 'w') as xml_file: + xml_file.write(xml_template.format(old_gray='0x555753')) + self.app = qubes.Qubes('/tmp/qubestest.xml', offline_mode=True) + self.assertEqual( + self.app.get_label('gray').color, '0x555555') + self.app.close() + del self.app + + with self.subTest('dont_replace_label'): + with open('/tmp/qubestest.xml', 'w') as xml_file: + xml_file.write(xml_template.format(old_gray='0x123456')) + self.app = qubes.Qubes('/tmp/qubestest.xml', offline_mode=True) + self.assertEqual( + self.app.get_label('gray').color, '0x123456') + self.app.close() + del self.app + class TC_90_Qubes(qubes.tests.QubesTestCase): def tearDown(self):