Skip to content
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

Commas in username causes error in nosy list #35

Closed
ericvsmith opened this issue Apr 26, 2019 · 8 comments
Closed

Commas in username causes error in nosy list #35

ericvsmith opened this issue Apr 26, 2019 · 8 comments
Assignees

Comments

@ericvsmith
Copy link
Member

User "Oliver Too, Eh?" created https://bugs.python.org/issue36727.

Because of the comma in the username, I couldn't reply to the issue via the bpo UI. It gave me an error: "property nosy: 'Oliver Too' is not a user.", then reformatted the nosy list as "Eh?,Oliver Too,docs@python,eric.smith,xtreak". I tried various combination of quotes and escape backslashes, to no avail. I ended up dropping the user from the nosy list and notifying them via direct email.

@tirkarthi also had the same issue, and ended up adding a reply to the issue via email to bpo to work around the problem.

Perhaps the user creation should prohibit commas?

@rouilj
Copy link

rouilj commented May 16, 2019

@rouilj
Copy link

rouilj commented Aug 7, 2019

See also: #39. One of the solutions to that issue will also solve this issue.

@berkerpeksag
Copy link
Member

@rouilj unfortunately changing userauditor will lead to the same UX issue as in #46. The user will still see the following message:

You will shortly receive an email to to confirm your registration. To complete the registration process, visit the link indicated in the email.

Would overriding RegisterAction and making something similar to:

https://github.com/psf/bpo-roundup/blob/68573d196f9a01786414d3b235252b9c857c3e08/roundup/cgi/actions.py#L1053-L1061

before:

https://github.com/psf/bpo-roundup/blob/68573d196f9a01786414d3b235252b9c857c3e08/roundup/cgi/actions.py#L1124

abort the registration with a user-friendly error message?

Currently, I have the following diff that prevents registering users with an invalid username:

diff --git a/detectors/userauditor.py b/detectors/userauditor.py
index d58eec5..eff098b 100644
--- a/detectors/userauditor.py
+++ b/detectors/userauditor.py
@@ -20,14 +20,25 @@
 #
 #$Id: userauditor.py,v 1.3 2006/09/18 03:24:38 tobias-herp Exp $
 
+import re
 import urlparse
 
+valid_username = re.compile(r'^[a-z0-9_.-]+$', re.IGNORECASE)
+
+
 def audit_user_fields(db, cl, nodeid, newvalues):
     ''' Make sure user properties are valid.
 
         - email address has no spaces in it
         - roles specified exist
     '''
+    if 'username' in newvalues:
+        if not valid_username.match(newvalues['username']):
+            raise ValueError(
+                'Username must consist only of the letters a-z (any case), '
+                'digits 0-9 and the symbols: ._-'
+            )
+
     if newvalues.has_key('address') and ' ' in newvalues['address']:
         raise ValueError, 'Email address must not contain spaces'
 
diff --git a/html/user.register.html b/html/user.register.html
index 65022e8..db00075 100644
--- a/html/user.register.html
+++ b/html/user.register.html
@@ -19,7 +19,10 @@
  </tr>
  <tr>
   <th class="required" i18n:translate="">Login Name</th>
-  <td tal:content="structure context/username/field">username</td>
+  <td>
+   <span tal:content="structure python:context.username.field(pattern='^[a-z0-9_.-]+$', required=True)">username</span>
+   Login name must consist only of the letters a-z (any case), digits 0-9 and the symbols: ._-
+  </td>
  </tr>
  <tr>
   <th class="required" i18n:translate="">Login Password</th>

But it would be nice to defer this step to Roundup without involving any client side validation.

@berkerpeksag berkerpeksag self-assigned this Aug 1, 2020
@berkerpeksag
Copy link
Member

In #39 (comment), you've proposed a similar solution, but I wonder if it's possible to trigger auditors without manually validating the input via self.client.parsePropsFromForm(create=1).

@rouilj
Copy link

rouilj commented Aug 1, 2020 via email

@berkerpeksag
Copy link
Member

Sadly no. The detector (auditor/reactor) mechanism requires an entry in the database. In the deferred (i.e. not instant) registration case the database interaction doesn't happen until after the email link is followed.

Ah, yes, I see that ConfRegoAction calls confirm_registration:

https://github.com/psf/bpo-roundup/blob/68573d196f9a01786414d3b235252b9c857c3e08/roundup/roundupdb.py#L108-L134

I think this is a pretty common operation and it seems to be happening for pretty much all the fields in the registration form. I've just tested that I can get the following message even if I tried to register with an existing username:

You will shortly receive an email to to confirm your registration. To complete the registration process, visit the link indicated in the email.

What do you think about adding a __active__ field to the _user table, create user on database with __active__ = false and then after OTK step has completed, update __active__ to true?

Or can't we consider a user record with an active OTK record inactive/unverified since we immediately remove the props from OTK table after creation? https://github.com/psf/bpo-roundup/blob/68573d196f9a01786414d3b235252b9c857c3e08/roundup/roundupdb.py#L130 In short, is it doable to split the functionality in confirm_registration into two separate steps?

@berkerpeksag
Copy link
Member

I've just pushed a slightly updated version of my inline patch in #35 (comment). We can continue discussing more general solutions here or somewhere else. Thanks!

@rouilj
Copy link

rouilj commented Aug 1, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants