Opens services file as utf-8 even in edge cases

In edge cases (usually when system locale is not installed) Gtk falls
back to 'C' (not C.utf-8 ...) locale. Fixed that to enforce utf-8 always.

fixes QubesOS/qubes-issues#4475
This commit is contained in:
Marta Marczykowska-Górecka 2018-12-28 17:40:35 +01:00
parent c16b9694b3
commit 6b0fa9551e
No known key found for this signature in database
GPG Key ID: 9A752C30B26FD04B

View File

@ -138,6 +138,7 @@ class NewFwRuleDlg(QtGui.QDialog, ui_newfwruledlg.Ui_NewFwRuleDlg):
if checked: if checked:
self.serviceComboBox.setEnabled(False) self.serviceComboBox.setEnabled(False)
class QubesFirewallRulesModel(QtCore.QAbstractItemModel): class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
def __init__(self, parent=None): def __init__(self, parent=None):
QtCore.QAbstractItemModel.__init__(self, parent) QtCore.QAbstractItemModel.__init__(self, parent)
@ -148,7 +149,7 @@ class QubesFirewallRulesModel(QtCore.QAbstractItemModel):
r"(?P<name>[a-z][a-z0-9-]+)\s+(?P<port>[0-9]+)/" r"(?P<name>[a-z][a-z0-9-]+)\s+(?P<port>[0-9]+)/"
r"(?P<protocol>[a-z]+)", r"(?P<protocol>[a-z]+)",
re.IGNORECASE) re.IGNORECASE)
with open('/etc/services', 'r') as file: with open('/etc/services', 'r', encoding='utf-8') as file:
for line in file: for line in file:
match = pattern.match(line) match = pattern.match(line)
if match is not None: if match is not None: