lib/core: Add ostree_validate_remote_name() for remote names

There are a few places in the code where ad-hoc validation was being
performed. Might as well formalise it a bit more.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #948
Approved by: cgwalters
This commit is contained in:
Philip Withnall authored and Atomic Bot committed 2017-06-20 21:52:22 +00:00
1 parent fd50c97322
commit 20dc9454b3
6 files changed
+62 -6

No files matched your search

+4 -4
View File
@@ -876,8 +876,8 @@ impl_repo_remote_add (OstreeRepo *self,
g_return_val_if_fail (url != NULL, FALSE);
g_return_val_if_fail (options == NULL || g_variant_is_of_type (options, G_VARIANT_TYPE ("a{sv}")), FALSE);
if (strchr (name, '/') != NULL)
return glnx_throw (error, "Invalid character '/' in remote name: %s", name);
if (!ostree_validate_remote_name (name, error))
return FALSE;
g_autoptr(OstreeRemote) remote = _ostree_repo_get_remote (self, name, NULL);
if (remote != NULL && if_not_exists)
@@ -1005,8 +1005,8 @@ impl_repo_remote_delete (OstreeRepo *self,
{
g_return_val_if_fail (name != NULL, FALSE);
if (strchr (name, '/') != NULL)
return glnx_throw (error, "Invalid character '/' in remote name: %s", name);
if (!ostree_validate_remote_name (name, error))
return FALSE;
g_autoptr(OstreeRemote) remote = NULL;
if (if_exists)