##// END OF EJS Templates
Restore rev param validation that was removed in r2840....
Jean-Philippe Lang -
r4428:84dd413f22b9
parent child
Show More
@@ -197,6 +197,9 class RepositoriesController < ApplicationController
197 end
197 end
198
198
199 private
199 private
200
201 REV_PARAM_RE = %r{^[a-f0-9]*$}i
202
200 def find_repository
203 def find_repository
201 @project = Project.find(params[:id])
204 @project = Project.find(params[:id])
202 @repository = @project.repository
205 @repository = @project.repository
@@ -205,6 +208,12 private
205 @path ||= ''
208 @path ||= ''
206 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
209 @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
207 @rev_to = params[:rev_to]
210 @rev_to = params[:rev_to]
211
212 unless @rev.to_s.match(REV_PARAM_RE) && @rev.to_s.match(REV_PARAM_RE)
213 if @repository.branches.blank?
214 raise InvalidRevisionParam
215 end
216 end
208 rescue ActiveRecord::RecordNotFound
217 rescue ActiveRecord::RecordNotFound
209 render_404
218 render_404
210 rescue InvalidRevisionParam
219 rescue InvalidRevisionParam
@@ -166,6 +166,12 class RepositoriesSubversionControllerTest < ActionController::TestCase
166 }
166 }
167 end
167 end
168
168
169 def test_invalid_revision
170 get :revision, :id => 1, :rev => 'something_weird'
171 assert_response 500
172 assert_error_tag :content => /was not found/
173 end
174
169 def test_revision_with_repository_pointing_to_a_subdirectory
175 def test_revision_with_repository_pointing_to_a_subdirectory
170 r = Project.find(1).repository
176 r = Project.find(1).repository
171 # Changes repository url to a subdirectory
177 # Changes repository url to a subdirectory
General Comments 0
You need to be logged in to leave comments. Login now