forked from Mirrors/flatpak-builder
Allow application ids containing "-"
For a long time we have been disallowing "-" in application names, which is different than what dbus allows for bus names. Also "-" used to be not allowed by GApplication in glib. This is in part because dbus object paths do *not* allow dashes, so you can't legally map from e.g. a valid name like "org.foo-bar.gazonk" to a valid path like "/org/foo-bar/gazonk". This is a problem because many existing apps already use "-" in the name, either as the last part (org.gnome.font-viewer) or because the dns name it refers to has a dash. This was recently discussed in the dbus community, and the result is to recommend that "-" in the bus names be converted to "_" in object paths. This change makes it also allowed to have "-" in a flatpak app id. For flatpak specifically we were relying on "-" not being allowed to handle the case of exporting "org.foo.App-symbolic.png". If "-" is allowed this name can conflict between apps called "org.foo.App-symbolic" and "org.foo.App". To handle this we add two special cases: * App ids can't end with "-symbolic". * Apps are allowed to export files with $appid-symbolic as prefix.tingping/wmclass
parent
cf47870ea6
commit
5c075525a8
|
@ -366,7 +366,7 @@ is_valid_initial_name_character (gint c)
|
|||
return
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c == '_');
|
||||
(c == '_') || (c == '-');
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
@ -387,10 +387,12 @@ is_valid_name_character (gint c)
|
|||
* ('.') character. All elements must contain at least one character.
|
||||
*
|
||||
* Each element must only contain the ASCII characters
|
||||
* "[A-Z][a-z][0-9]_". Elements may not begin with a digit.
|
||||
* "[A-Z][a-z][0-9]_-". Elements may not begin with a digit.
|
||||
*
|
||||
* App names must not begin with a '.' (period) character.
|
||||
*
|
||||
* App names must not end with "-symbolic".
|
||||
*
|
||||
* App names must not exceed 255 characters in length.
|
||||
*
|
||||
* The above means that any app name is also a valid DBus well known
|
||||
|
@ -431,6 +433,16 @@ flatpak_is_valid_name (const char *string,
|
|||
goto out;
|
||||
}
|
||||
|
||||
/* To special case symbolic icons we allow org.foo.Bar to export
|
||||
files named "org.foo.Bar-symbolic.*". To avoid conflicts for
|
||||
we then forbid app names ending with "-symbolic". */
|
||||
if (G_UNLIKELY (g_str_has_suffix (string, "-symbolic")))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Name are not allowed to end with '-symbolic'");
|
||||
goto out;
|
||||
}
|
||||
|
||||
end = string + len;
|
||||
|
||||
s = string;
|
||||
|
@ -503,7 +515,9 @@ flatpak_has_name_prefix (const char *string,
|
|||
return
|
||||
*rest == 0 ||
|
||||
*rest == '.' ||
|
||||
!is_valid_name_character (*rest);
|
||||
!is_valid_name_character (*rest) ||
|
||||
/* Special case -symbolic icon names */
|
||||
g_str_has_prefix (rest, "-symbolic.");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
|
Loading…
Reference in New Issue