File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,7 +115,13 @@ def requested_email
115115 end
116116
117117 def target_email_allowed?
118- LEGIT_ADMIN_DOMAINS . any? { |d | requested_email . end_with? ( d ) }
118+ domain = requested_email . to_s . split ( '@' , 2 ) . last &.downcase
119+ return false if domain . blank?
120+
121+ LEGIT_ADMIN_DOMAINS . any? do |d |
122+ legit = d . to_s . downcase
123+ domain == legit || domain . end_with? ( ".#{ legit } " )
124+ end
119125 end
120126
121127 def next_owner_email
Original file line number Diff line number Diff line change 119119 expect ( flash . alert ) . to include ( 'contactez le support' )
120120 end
121121 end
122+
123+ context 'when the requested email is on a domain that only matches a legit suffix without an `@` boundary' do
124+ let ( :requested_email ) { 'admin@evilgouv.fr' }
125+
126+ it 'rejects the email change' do
127+ expect ( user . unconfirmed_email ) . to be_nil
128+ expect ( response ) . to redirect_to ( profil_path )
129+ expect ( flash . alert ) . to include ( 'contactez le support' )
130+ end
131+ end
122132 end
123133
124134 context 'when the user has an administrateur role but no instructeur role' do
You can’t perform that action at this time.
0 commit comments