all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH] utils: cleanup username/userid regex and verify
Date: Wed, 14 Feb 2024 10:15:01 +0100	[thread overview]
Message-ID: <20240214091503.16979-1-g.goller@proxmox.com> (raw)

Cleaned up the verify_username function and userid regex after the
recent changes to minLength have been applied [0].

[0]: https://lists.proxmox.com/pipermail/pmg-devel/2023-September/002521.html

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PMG/Utils.pm | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/PMG/Utils.pm b/src/PMG/Utils.pm
index 12b3ed5..8f7d438 100644
--- a/src/PMG/Utils.pm
+++ b/src/PMG/Utils.pm
@@ -72,13 +72,12 @@ PVE::JSONSchema::register_standard_option('pmg-endtime', {
     optional => 1,
 });
 
-PVE::JSONSchema::register_format('pmg-userid', \&verify_username);
 sub verify_username {
     my ($username, $noerr) = @_;
 
     $username = '' if !$username;
     my $len = length($username);
-    if ($len < 3) {
+    if ($len < 1) {
 	die "user name '$username' is too short\n" if !$noerr;
 	return undef;
     }
@@ -102,8 +101,8 @@ sub verify_username {
 
 PVE::JSONSchema::register_standard_option('userid', {
     description => "User ID",
-    type => 'string', format => 'pmg-userid',
-    minLength => 4,
+    type => 'string',
+    pattern => '[^\s:\/]{1,60}',
     maxLength => 64,
 });
 
-- 
2.43.0





             reply	other threads:[~2024-02-14  9:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14  9:15 Gabriel Goller [this message]
2024-02-14 11:55 ` Stoiko Ivanov
2024-02-14 13:54   ` Gabriel Goller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240214091503.16979-1-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pmg-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal