File tree 3 files changed +23
-5
lines changed
3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -98,11 +98,12 @@ def self.user_to_user_token(user)
98
98
99
99
# Strip leading and trailing whitespace
100
100
def strip_whitespace
101
- # Don't mess with existing keys (since cannot change key text anyway)
102
- return if !new_record?
103
-
104
101
self . title = title . strip
105
- self . key = key . strip
102
+
103
+ # Don't mess with existing keys (since cannot change key text anyway)
104
+ if new_record?
105
+ self . key = key . strip
106
+ end
106
107
end
107
108
108
109
# Remove control characters from key
Original file line number Diff line number Diff line change @@ -16,6 +16,8 @@ class RepositoryMirror < ActiveRecord::Base
16
16
17
17
validate :check_refspec
18
18
19
+ before_validation :strip_whitespace
20
+
19
21
named_scope :active , { :conditions => { :active => RepositoryMirror ::STATUS_ACTIVE } }
20
22
named_scope :inactive , { :conditions => { :active => RepositoryMirror ::STATUS_INACTIVE } }
21
23
@@ -77,6 +79,12 @@ def to_s
77
79
78
80
protected
79
81
82
+ # Strip leading and trailing whitespace
83
+ def strip_whitespace
84
+ self . url = url . strip
85
+ self . explicit_refspec = explicit_refspec . strip
86
+ end
87
+
80
88
# Put backquote in front of crucial characters
81
89
def dequote ( in_string )
82
90
in_string . gsub ( /[$,"\\ \n ]/ ) { |x | "\\ " +x }
Original file line number Diff line number Diff line change @@ -7,10 +7,12 @@ class RepositoryPostReceiveUrl < ActiveRecord::Base
7
7
attr_accessible :url , :mode , :active
8
8
9
9
validates_uniqueness_of :url , :scope => [ :project_id ]
10
- validates_presence_of :project_id , :url
10
+ validates_presence_of :project_id
11
11
validates_format_of :url , :with => URI ::regexp ( %w( http https ) )
12
12
validates_associated :project
13
13
14
+ before_validation :strip_whitespace
15
+
14
16
named_scope :active , { :conditions => { :active => RepositoryPostReceiveUrl ::STATUS_ACTIVE } }
15
17
named_scope :inactive , { :conditions => { :active => RepositoryPostReceiveUrl ::STATUS_INACTIVE } }
16
18
@@ -25,4 +27,11 @@ def mode= (value)
25
27
def to_s
26
28
return File . join ( "#{ project . identifier } -#{ url } " )
27
29
end
30
+
31
+ protected
32
+
33
+ # Strip leading and trailing whitespace
34
+ def strip_whitespace
35
+ self . url = url . strip
36
+ end
28
37
end
You can’t perform that action at this time.
0 commit comments