diff options
author | Douwe Maan <douwe@gitlab.com> | 2015-04-21 12:00:08 +0200 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2015-04-24 14:49:23 +0200 |
commit | fac1f83fd51d4d6cc6e8a0c571507bca4460b514 (patch) | |
tree | ad8b78c99d39addeaa777a1750e7ecd5e96fca0b /app/models | |
parent | c0116926c743818b2593474946abb40b56d8fefa (diff) | |
download | gitlab-ce-fac1f83fd51d4d6cc6e8a0c571507bca4460b514.tar.gz |
Properly migrate users with usernames like "." or "..".
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/namespace.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 24363a853d8..4c760ac6176 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -66,9 +66,13 @@ class Namespace < ActiveRecord::Base path.gsub!(/\.+\z/, "") path.gsub!(/[^a-zA-Z0-9_\-\.]/, "") + # Users with the great usernames of "." or ".." would end up with a blank username. + # Work around that by setting their username to "blank", followed by a counter. + path = "blank" if path.blank? + counter = 0 base = path - while Namespace.by_path(path).present? + while Namespace.find_by_path_or_name(path) counter += 1 path = "#{base}#{counter}" end |