-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save only valid D-Bus Names #454
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,12 +23,15 @@ const {GObject} = imports.gi; | |
const {FlatpakSharedModel} = imports.models.shared; | ||
const {FlatsealOverrideStatus} = imports.models.overrideStatus; | ||
|
||
/* https://dbus.freedesktop.org/doc/dbus-specification.html */ | ||
const EXP = /^(([A-Z]|[a-z]|[0-9]|_|-)+)(\.(([A-Z]|[a-z]|[0-9]|_|-)+))+(\.\*){0,1}$/; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make this better than I currently do it, how about we officially move the definition of this esoteric regexp to this model (e.g. |
||
|
||
var FlatpakSessionBusModel = GObject.registerClass({ | ||
GTypeName: 'FlatpakSessionBusModel', | ||
}, class FlatpakSessionBusModel extends FlatpakSharedModel { | ||
_init() { | ||
super._init({}); | ||
this._expression = new RegExp(EXP); | ||
} | ||
|
||
getPermissions() { | ||
|
@@ -180,7 +183,9 @@ var FlatpakSessionBusModel = GObject.registerClass({ | |
saveToKeyFile(keyFile) { | ||
const group = this.constructor.getGroup(); | ||
Object.entries(this._overrides).forEach(([key, value]) => { | ||
keyFile.set_value(group, key, value); | ||
if (this._expression.test(key)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For consistency, instead of doing this here, can you move this to |
||
keyFile.set_value(group, key, value); | ||
} | ||
}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
([A-Z]|[a-z])
->([A-Za-z])
)(untested suggestion)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This RegEx is not from me. It is already used in Flatseal.
Flatseal/src/widgets/busNameRow.js
Lines 27 to 28 in 562ddec
It is used to display the valid icon in the D-Bus edit field. If it is wrong, it should be fixed in both places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hypens are allowed, but just on the last segment of the name