Commit fac1f83f authored by Douwe Maan's avatar Douwe Maan

Properly migrate users with usernames like "." or "..".

parent c0116926
...@@ -66,9 +66,13 @@ class Namespace < ActiveRecord::Base ...@@ -66,9 +66,13 @@ class Namespace < ActiveRecord::Base
path.gsub!(/\.+\z/, "") path.gsub!(/\.+\z/, "")
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "") 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 counter = 0
base = path base = path
while Namespace.by_path(path).present? while Namespace.find_by_path_or_name(path)
counter += 1 counter += 1
path = "#{base}#{counter}" path = "#{base}#{counter}"
end end
......
...@@ -15,6 +15,10 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration ...@@ -15,6 +15,10 @@ class RemovePeriodsAtEndsOfUsernames < ActiveRecord::Migration
path.gsub!(/\.+\z/, "") path.gsub!(/\.+\z/, "")
path.gsub!(/[^a-zA-Z0-9_\-\.]/, "") 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 counter = 0
base = path base = path
while Namespace.find_by_path_or_name(path) while Namespace.find_by_path_or_name(path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment