Problem/Motivation
This is a problem for both 6.x and 7.x. The name field for users allows the @ symbol despite the #description for the field saying otherwise. With 6.17, the user module was brought in line with 7.x-dev in allowing apostrophes as well as period, underscore, hyphen, and @, so its #description for the name field is now even more incorrect than it was before (doesn't mention apostrophes)
The code to verify the acceptable characters is in comment #55.
There is also an outstanding issue to change the allowed characters: #1290528: Disallow English symbols and math characters in Username
Current wording:
Spaces are allowed; punctuation is not allowed except periods, hyphens, apostrophes, and underscores.
Proposed resolution
The sentence should be changed to :
Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign.
User interface changes
Before:

After:
Beta phase evaluation
| Issue category | Bug because the current description incorrectly identifies which characters are allowed in username field. |
|---|---|
| Issue priority | Normal |
| Unfrozen changes | Unfrozen because it only changes a translatable string. |
| Prioritized changes | The main goal of this issue is usability |
| Disruption | Not disruptive because it only affects words in a translatable string. |
| Comment | File | Size | Author |
|---|---|---|---|
| #70 | before_patch.JPG | 26.71 KB | Trupti Bhosale |
| #70 | validation_after_patch.JPG | 43.47 KB | Trupti Bhosale |
| #70 | after_patch_1.JPG | 123.83 KB | Trupti Bhosale |
| #67 | fix_the_allowed-827468-67.patch | 1.67 KB | aburrows |
| #67 | Configure_site___Drupal.png | 379.14 KB | aburrows |
Comments
Comment #1
mgriego commentedComment #2
dddave commentedConfirmed. I guess D8 is the place to work on it.
Comment #3
bleen commentedmore susinct:
Comment #4
drupal_was_my_past commentedHow about this: Spaces as well as the following special characters are allowed: @.'_-
Patch attached.
Comment #5
droplet commentedmore than @.'_- are allowed
I started another new issue related to this topic: #1290528: Disallow English symbols and math characters in Username
Comment #6
dcam commentedClosed a duplicate issue.
Comment #7
dcam commentedOops. I didn't add the related duplicate issue correctly.
Comment #8
meeli commentedThis is tricky. So the questions I think we need to ask are:
Comment #9
gsharm commentedComment #10
gsharm commentedComment #11
ifrikComment #12
ifrik"Spaces as well as the following special characters are allowed" is a good solution to shorten the sentences and to get around the akward semicolon.
However, the names of the allowed characters should be spelled out for readability, because characters such as apostrophes are not always distinguishable from similar characters, especially when the help text is in a small font size.
Alternatively, the characters could be placed after their name.
Comment #13
latikas commentedHow about this: Spaces and special characters are also allowed like periods(.), hyphens(-), apostrophes('""'), underscore (_) and the @ symbol.
Patch attached.
Comment #14
latikas commentedRe-rolled patch according to #12
Comment #17
latikas commentedComment #21
anil.gangwal commentedupdating credit
Comment #22
anil.gangwal commentedupdating credit
Comment #23
duaelfrThe modules/user/user.module file does not exist anymore and forms now follows the PSR-4 standard.
You should now look in core/modules/user/src/AccountForm.php
Comment #24
paulmartin84 commentedComment #25
paulmartin84 commentedComment #26
paulmartin84 commentedIn #25 I mistakenly changed the SiteConfigureForm, please ignore the previous patch, Here is the correct one that targets the AccountForm,
Comment #27
paulmartin84 commentedComment #29
danharper commentedWorking on this.
Comment #30
danylevskyiI'm a mentor. Helping @danharper to work on the issue.
Comment #31
nlisgo commentedGO @danharper!
Comment #32
danharper commentedPatch applies properly and solves the issue marking as RTBC.
Comment #33
alimac commentedIt would be nice to have screenshots of this. @danylevskyi, @danharper - can you work with another sprinter to add screenshots to this issue?
Comment #34
alimac commenteddouble post
Comment #35
pektinasen commentedI'll do the screenshots.
Comment #36
pektinasen commentedComment #37
pektinasen commentedComment #38
alimac commentedGreat. Can we add the screenshots to the issue summary and also use the issue summary template?
https://www.drupal.org/issue-summaries
Comment #39
fatfish commentedComment #40
alimac commentedI am setting the priority to Normal. Per https://www.drupal.org/core/issue-priority "minor" issues are cosmetic changes. Here the description was giving incorrect information about what characters are allowed.
Comment #41
danylevskyiComment #42
alimac commentedAdded a beta evaluation.
Comment #43
alimac commentedComment #44
alimac commentedPer suggestion from @webchick, I searched for the string "Spaces are allowed;" to make sure that this is the only instance of the string, but it also shows up in another file (site configuration form). The description should be changed in both places.
core/lib/Drupal/Core/Installer/Form/SiteConfigureForm.php 177: '#description' => $this->t('Spaces are allowed; punctuation is not allowed except for periods, hyphens, and underscores.'),Also, we should run this by UX maintainer since this change affects a form used by a lot of people.
Comment #45
alimac commentedAlso, let's simplify the string to: "These special characters are allowed: space, period (.), hyphen (-), apostrophes (‘), underscore (_), and the @ sign."
Comment #46
fatfish commentedComment #47
danylevskyiComment #48
yesct commentedWhy double quotes? I think that should stay single quotes.
Comment #49
alimac commentedAddressing comment #48.
Comment #50
paulmartin84 commented(') is an Apostrophe and (‘) is a Left Single Quotation mark Which one is this issue referring to?
Comment #51
webchickSadly, when this patch was presented in front of everyone at DrupalCon Barcelona, we discovered that we don't know what ' is. So we should figure that out. ;)
Comment #52
alimac commentedGood question. I tested both and they are both accepted.
Comment #53
yesct commentedI think we need to check the code and see what is actually allowed.
Then... we might need to re-evaluate if we actually want to list them *all*.
And I think a reference, added to the issue summary, clarifying what is a single quote, apostrophe, smart quote, back tick, etc.
Comment #54
realityloop commentedI checked with a program called Ultra Character Map on OSX
' is called "Apostrophe" and doesn't have a unicode value
` is called "Grave Accent" it is unicode u0060
‘ is called a "Left Single Quotation Mark" it is unicode u2018
’ is called a "Right Single Quotation Mark" it is unicode u2019
Comment #55
john cook commentedIn
UserNameConstraintValidator::validate()the code to check for invalid username characters is:Comment #56
yesct commentedrelated info as to how we format the *code* for the string:
https://www.drupal.org/coding-standards#quotes
Comment #57
john cook commentedComment #58
john cook commentedUpdated issue summary.
Comment #59
realityloop commentedI think it makes sense to only tell people the "logical" characters..
#448074: @ style mentions for usernames which send notifications for D.o is possibly relevant
Comment #60
susanb commentedI'm going to make an attempt to clarify the text and submit a new patch for review.
Comment #61
ifrikLooks like several people were trying out all kinds of special characters yesterday after the Live Review, and lots of them can be used - too many for making a definite list.
The best solution might be to make a non-exclusive list of examples:
Several special characters are allowed, including space, period (.), hyphen (-), apostrophes (‘), underscore (_), the @ sign, and more.And only include examples that we can clearly identify.
Comment #62
yesct commentedok. but I think if we are going to include the word "apostrophe" then it should be ' and not ‘ which is a Left Single Quotation Mark.
@susanb maybe you had some questions when you tried?
I suggest
without the "and more" since the "including" says that.
Comment #63
yesct commenteduhh.. and that is the only plural, ... and and. :)
so really I suggest. ...
Comment #64
duaelfrI can confirm what @ifrik says in #61 ;)
Can't we just write something like the following?
Or what about explaining the characters that are *not* allowed?
Comment #65
aburrows commentedThe validation is working, so its more the case of changing the text, I agree with YesCT and we should make it identifieable with the symbols between ().
Comment #66
aburrows commentedComment #67
aburrows commentedPatch and screenshot attached, implementing YesCT suggestion
Comment #70
Trupti Bhosale commentedVerified the issue with the patch ' fix_the_allowed-827468-67.patch'.
1.The phrase is now displayed as ' Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign. '
2.Error is displayed if other special characters are written in username
Attached snapshot for reference.
Comment #71
Trupti Bhosale commentedComment #72
alimac commented@Truptti: thanks for reviewing the patch!
Can you update the issue summary and replace the old screenshots with yours? Also, the proposed resolution needs to be updated to reflect @YesCT's suggestion in #63.
Comment #73
Trupti Bhosale commentedComment #74
Trupti Bhosale commentedComment #75
Trupti Bhosale commentedComment #76
Trupti Bhosale commented@alimac : Updated the screenshot and the proposed resolution in the issue summary.
Comment #80
alvar0hurtad0It seems that the state is automatically changed to a failure in the test. But the patch pass the tests now.
Comment #83
webchickYAY! So happy to see this in! Sorry it didn't happen LIVE at Drupalcon "Brewshaloona"! ;)
Committed and pushed to 8.0.x. Thanks!!
(Sorry, not sure who to credit so just crediting everyone.)
Comment #84
webchick