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:
Before

After:
After

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
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.
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgriego’s picture

Title: Fix the allowed punctuation wording in the user_edit form » Fix the allowed punctuation wording in user_edit_form
dddave’s picture

Version: 7.x-dev » 8.x-dev

Confirmed. I guess D8 is the place to work on it.

bleen’s picture

more susinct:

'#description' => t('Spaces as well as these special characters are allowed: @.\'_-'),
drupal_was_my_past’s picture

Component: user.module » user interface text
Priority: Normal » Minor
Status: Active » Needs review
FileSize
711 bytes

How about this: Spaces as well as the following special characters are allowed: @.'_-

Patch attached.

droplet’s picture

Status: Needs review » Needs work

more than @.'_- are allowed

I started another new issue related to this topic: #1290528: Disallow English symbols and math characters in Username

dcam’s picture

Issue summary: View changes

Closed a duplicate issue.

dcam’s picture

Oops. I didn't add the related duplicate issue correctly.

meeli’s picture

This is tricky. So the questions I think we need to ask are:

  • Do we need to provide a list of every disallowed character?
  • Is there some way to summarise the disallowed characters (eg. Non-printable ISO-88591 and non-breaking spaces, soft hypens, punctuation and math symbols, various space characters, bidirectional text overrides and various text hinting characters) that might do the trick?
  • Does this text need to be in this interface, or can we link to another resource that lists the chars?
gsharm’s picture

Assigned: Unassigned » gsharm
gsharm’s picture

Assigned: gsharm » Unassigned
ifrik’s picture

Issue tags: +Barcelona2015
ifrik’s picture

"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.

latikas’s picture

How about this: Spaces and special characters are also allowed like periods(.), hyphens(-), apostrophes('""'), underscore (_) and the @ symbol.

Patch attached.

latikas’s picture

Status: Needs work » Needs review

Re-rolled patch according to #12

Status: Needs review » Needs work

The last submitted patch, 13: user-name-help-text-827468-5.patch, failed testing.

The last submitted patch, 13: user-name-help-text-827468-5.patch, failed testing.

latikas’s picture

Status: Needs review » Needs work

The last submitted patch, 17: user-name-help-text-827468-6.patch, failed testing.

The last submitted patch, 13: user-name-help-text-827468-5.patch, failed testing.

The last submitted patch, 17: user-name-help-text-827468-6.patch, failed testing.

anil.gangwal’s picture

Assigned: Unassigned » anil.gangwal

updating credit

anil.gangwal’s picture

Assigned: anil.gangwal » Unassigned

updating credit

DuaelFr’s picture

Issue tags: +Needs reroll, +Novice

The 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

paulmartin84’s picture

Assigned: Unassigned » paulmartin84
paulmartin84’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
884 bytes
paulmartin84’s picture

FileSize
813 bytes

In #25 I mistakenly changed the SiteConfigureForm, please ignore the previous patch, Here is the correct one that targets the AccountForm,

paulmartin84’s picture

Assigned: paulmartin84 » Unassigned

The last submitted patch, 25: fix_the_allowed-827468-25.patch, failed testing.

danharper’s picture

Working on this.

danylevskyi’s picture

I'm a mentor. Helping @danharper to work on the issue.

nlisgo’s picture

GO @danharper!

danharper’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies properly and solves the issue marking as RTBC.

alimac’s picture

Issue tags: +Needs screenshots

It would be nice to have screenshots of this. @danylevskyi, @danharper - can you work with another sprinter to add screenshots to this issue?

alimac’s picture

double post

pektinasen’s picture

I'll do the screenshots.

pektinasen’s picture

pektinasen’s picture

  1. Before:
  2. After:
alimac’s picture

Great. Can we add the screenshots to the issue summary and also use the issue summary template?
https://www.drupal.org/issue-summaries

fatfish’s picture

Issue summary: View changes
alimac’s picture

Priority: Minor » Normal

I 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.

danylevskyi’s picture

Issue summary: View changes
alimac’s picture

Issue summary: View changes

Added a beta evaluation.

alimac’s picture

Issue summary: View changes
alimac’s picture

Status: Reviewed & tested by the community » Needs work

Per 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.

alimac’s picture

Issue summary: View changes

Also, let's simplify the string to: "These special characters are allowed: space, period (.), hyphen (-), apostrophes (‘), underscore (_), and the @ sign."

fatfish’s picture

danylevskyi’s picture

Status: Needs work » Needs review
YesCT’s picture

Status: Needs review » Needs work

Why double quotes? I think that should stay single quotes.

alimac’s picture

Status: Needs work » Needs review
FileSize
1.66 KB
827 bytes

Addressing comment #48.

paulmartin84’s picture

(') is an Apostrophe and (‘) is a Left Single Quotation mark Which one is this issue referring to?

webchick’s picture

Sadly, 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. ;)

alimac’s picture

(') is an Apostrophe and (‘) is a Left Single Quotation mark Which one is this issue referring to?

Good question. I tested both and they are both accepted.

YesCT’s picture

I 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.

realityloop’s picture

I 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

John Cook’s picture

In UserNameConstraintValidator::validate() the code to check for invalid username characters is:

preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)
|| preg_match(
'/[\x{80}-\x{A0}' .       // Non-printable ISO-8859-1 + NBSP
'\x{AD}' .                // Soft-hyphen
'\x{2000}-\x{200F}' .     // Various space characters
'\x{2028}-\x{202F}' .     // Bidirectional text overrides
'\x{205F}-\x{206F}' .     // Various text hinting characters
'\x{FEFF}' .              // Byte order mark
'\x{FF01}-\x{FF60}' .     // Full-width latin
'\x{FFF9}-\x{FFFD}' .     // Replacement characters
'\x{0}-\x{1F}]/u',        // NULL byte and control characters
$name)
YesCT’s picture

related info as to how we format the *code* for the string:
https://www.drupal.org/coding-standards#quotes

single quote strings should be used by default. Their use is recommended except in two cases:

Deliberate in-line variable interpolation, e.g. "<h2>$header</h2>".
Translated strings where one can avoid escaping single quotes by enclosing the string in double quotes. One such string would be "He's a good person." It would be 'He\'s a good person.' with single quotes. Such escaping may not be handled properly by .pot file generators for text translation, and it's also somewhat awkward to read.
John Cook’s picture

John Cook’s picture

Issue summary: View changes

Updated issue summary.

realityloop’s picture

I 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

susanb’s picture

Status: Needs review » Needs work

I'm going to make an attempt to clarify the text and submit a new patch for review.

ifrik’s picture

Looks 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.

YesCT’s picture

ok. 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

Several special characters are allowed, including space, period (.), hyphen (-), apostrophes ('), underscore (_), the @ sign.

without the "and more" since the "including" says that.

YesCT’s picture

uhh.. and that is the only plural, ... and and. :)

so really I suggest. ...

Several special characters are allowed, including space, period (.), hyphen (-), apostrophe ('), underscore (_), and the @ sign.
DuaelFr’s picture

Issue summary: View changes
FileSize
55.24 KB

I can confirm what @ifrik says in #61 ;)

Can't we just write something like the following?

Most of the special characters are allowed, including space, period (.), hyphen (-), apostrophes ('), underscore (_), the @ sign.

Or what about explaining the characters that are *not* allowed?

Most of the special characters are allowed, except all non-printing characters like invisible or fake spaces, line jumps or right-to-left marks for example.

aburrows’s picture

FileSize
34.21 KB

The 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 ().

aburrows’s picture

Assigned: Unassigned » aburrows
aburrows’s picture

Status: Needs work » Needs review
FileSize
148.57 KB
379.14 KB
1.67 KB

Patch and screenshot attached, implementing YesCT suggestion

Status: Needs review » Needs work

The last submitted patch, 67: fix_the_allowed-827468-67.patch, failed testing.

Status: Needs work » Needs review
Truptti’s picture

Verified 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.

Truptti’s picture

Status: Needs review » Reviewed & tested by the community
alimac’s picture

@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.

Truptti’s picture

Issue summary: View changes
Truptti’s picture

Issue summary: View changes
Truptti’s picture

Issue summary: View changes
Truptti’s picture

@alimac : Updated the screenshot and the proposed resolution in the issue summary.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 67: fix_the_allowed-827468-67.patch, failed testing.

alvar0hurtad0’s picture

Status: Needs work » Reviewed & tested by the community

It seems that the state is automatically changed to a failure in the test. But the patch pass the tests now.

  • webchick committed f49a8a4 on 8.0.x
    Issue #827468 by paulmartin84, latikas, aburrows, alimac, fatfish,...

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 67: fix_the_allowed-827468-67.patch, failed testing.

webchick’s picture

Status: Needs work » Fixed

YAY! 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.)

Oprah handing out commit credits. ;)

webchick’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.