e00bde3c5e4bcddafdbfec9be50b83403500a913

Author: Robin Luckey

Date: 2009-05-13 11:08:54 -0700

[CHANGE] Svn: Relax validation rules for usernames to allow email addresses.

diff --git a/lib/scm/adapters/svn/validation.rb b/lib/scm/adapters/svn/validation.rb index 15dabde..e31d268 100644 --- a/lib/scm/adapters/svn/validation.rb +++ b/lib/scm/adapters/svn/validation.rb @@ -16,6 +16,14 @@ module Scm::Adapters self end + # Subversion usernames have been relaxed from the abstract rules. We allow email names as usernames. + def validate_username + return nil unless @username + return nil if @username.length == 0 + return [:username, "The username must not be longer than 32 characters."] unless @username.length <= 32 + return [:username, "The username contains illegal characters."] unless @username =~ /^\w[\w@\.\+\-]*$/ + end + # If the URL is a simple directory path, make sure it is prefixed by file:// def path_to_file_url(path) url =~ /:\/\// ? url : 'file://' + File.expand_path(path) diff --git a/test/unit/svn_validation_test.rb b/test/unit/svn_validation_test.rb index 6eb07b2..bb562f6 100644 --- a/test/unit/svn_validation_test.rb +++ b/test/unit/svn_validation_test.rb @@ -2,6 +2,12 @@ require File.dirname(__FILE__) + '/../test_helper' module Scm::Adapters class SvnValidationTest < Scm::Test + def test_valid_usernames + [nil,'','joe_36','a'*32,'robin@ohloh.net'].each do |username| + assert !SvnAdapter.new(:username => username).validate_username + end + end + def test_rejected_urls [ nil, "", "foo", "http:/", "http:://", "http://", "sourceforge.net/svn/project/trunk", # missing a protocol prefix