Allow points and dashes in the username.

This reverts b3ca504c40. We don't quite know why that was added, but we assume it's because of format strings. Some pre-2011 users exist that still have dots or dashes in their username, and those accounts are somewhat broken now.

closes #8266
This commit is contained in:
Dennis Schubert 2021-07-04 20:34:07 +02:00 committed by Benjamin Neff
parent 8f804e376a
commit 407f51d5a3
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
5 changed files with 9 additions and 11 deletions

View file

@ -10,6 +10,7 @@
## Features
* Add tags to tumblr posts [#8244](https://github.com/diaspora/diaspora/pull/8244)
* Add blocks to the archive export [#8263](https://github.com/diaspora/diaspora/pull/8263)
* Allow points and dashes in the username [#8266](https://github.com/diaspora/diaspora/pull/8266)
# 0.7.15.0

View file

@ -36,10 +36,8 @@ class User < ApplicationRecord
before_validation :set_current_language, :on => :create
before_validation :set_default_color_theme, on: :create
validates :username, :presence => true, :uniqueness => true
validates_format_of :username, :with => /\A[A-Za-z0-9_]+\z/
validates_length_of :username, :maximum => 32
validates_exclusion_of :username, :in => AppConfig.settings.username_blacklist
validates :username, presence: true, uniqueness: true, format: {with: /\A[A-Za-z0-9_.\-]+\z/},
length: {maximum: 32}, exclusion: {in: AppConfig.settings.username_blacklist}
validates_inclusion_of :language, :in => AVAILABLE_LANGUAGE_CODES
validates :color_theme, inclusion: {in: AVAILABLE_COLOR_THEMES}, allow_blank: true
validates_format_of :unconfirmed_email, :with => Devise.email_regexp, :allow_blank => true

View file

@ -32,7 +32,7 @@
placeholder: t("registrations.new.username"),
title: t("registrations.new.enter_username"),
required: true,
pattern: "[A-Za-z0-9_]+",
pattern: "[A-Za-z0-9_.\-]+",
aria: {labelledby: "usernameLabel"}
- if mobile

View file

@ -186,7 +186,11 @@ Rails.application.routes.draw do
post 'by_handle' => :retrieve_remote, :as => 'person_by_handle'
end
end
get '/u/:username' => 'people#show', :as => 'user_profile', :constraints => { :username => /[^\/]+/ }
# Note: The contraint for this route's username parameter cannot be removed.
# This constraint turns off the format parameter, so that an username
# doctor.example would not try to render the user `doctor` in `example` format.
get "/u/:username" => "people#show", :as => "user_profile", :constraints => {username: %r{[^/]+}}
# External

View file

@ -267,11 +267,6 @@ describe User, :type => :model do
expect(alice).not_to be_valid
end
it 'should not contain periods' do
alice.username = "kittens."
expect(alice).not_to be_valid
end
it "can be 32 characters long" do
alice.username = "hexagoooooooooooooooooooooooooon"
expect(alice).to be_valid