Neither - nor _ need shell quoting, and as long as they are not the
first character, permitting them in a plugin or filter name may make
the command line easier to read. A restriction against a leading
digit is new, but hopefully does not break any existing plugins.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
It turns out I can't name a filter 'tls-fallback' without a slight
tweak. Our code for is_short_name() already accepts such names, but
our documentation and backend_load did not.
I'm undecided on whether rejecting a plugin beginning with a digit is
a good idea; as written, this patch would forbid a plugin named '9p',
but it is a one-line tweak to allow it (ascii_isalnum instead of
ascii_isalpha).
docs/nbdkit-filter.pod | 3 ++-
docs/nbdkit-plugin.pod | 3 ++-
server/backend.c | 10 ++++++++--
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/docs/nbdkit-filter.pod b/docs/nbdkit-filter.pod
index 3c7527d4..361a70f1 100644
--- a/docs/nbdkit-filter.pod
+++ b/docs/nbdkit-filter.pod
@@ -201,7 +201,8 @@ methods.
const char *name;
This field (a string) is required, and B<must> contain only ASCII
-alphanumeric characters and be unique amongst all filters.
+alphanumeric characters as well as dash or underscore, must begin with
+a letter, and be unique amongst all filters.
=head2 C<.longname>
diff --git a/docs/nbdkit-plugin.pod b/docs/nbdkit-plugin.pod
index 3d573b33..c961c116 100644
--- a/docs/nbdkit-plugin.pod
+++ b/docs/nbdkit-plugin.pod
@@ -471,7 +471,8 @@ an indication of failure. It has the following prototype:
const char *name;
This field (a string) is required, and B<must> contain only ASCII
-alphanumeric characters and be unique amongst all plugins.
+alphanumeric characters as well as dash or underscore, must begin with
+a letter, and be unique amongst all filters.
=head2 C<.version>
diff --git a/server/backend.c b/server/backend.c
index 8f4fed9d..046aacb4 100644
--- a/server/backend.c
+++ b/server/backend.c
@@ -98,10 +98,16 @@ backend_load (struct backend *b, const char *name, void (*load)
(void))
program_name, b->filename, b->type);
exit (EXIT_FAILURE);
}
- for (i = 0; i < len; ++i) {
+ if (! ascii_isalpha (*name)) {
+ fprintf (stderr,
+ "%s: %s: %s.name ('%s') field must begin with an ASCII
letter\n",
+ program_name, b->filename, b->type, name);
+ exit (EXIT_FAILURE);
+ }
+ for (i = 1; i < len; ++i) {
unsigned char c = name[i];
- if (! ascii_isalnum (c)) {
+ if (! ascii_isalnum (c) && c != '-' && c != '_') {
fprintf (stderr,
"%s: %s: %s.name ('%s') field "
"must contain only ASCII alphanumeric characters\n",
--
2.28.0
Show replies by date