end
end
-private
+ private
+
+ REV_PARAM_RE = %r{^[a-f0-9]*$}i
+
def find_repository
@project = Project.find(params[:id])
@repository = @project.repository
@path ||= ''
@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].strip
@rev_to = params[:rev_to]
+
+ unless @rev.to_s.match(REV_PARAM_RE) && @rev.to_s.match(REV_PARAM_RE)
+ if @repository.branches.blank?
+ raise InvalidRevisionParam
+ end
+ end
rescue ActiveRecord::RecordNotFound
render_404
rescue InvalidRevisionParam
}
end
+ def test_invalid_revision
+ get :revision, :id => 1, :rev => 'something_weird'
+ assert_response 500
+ assert_error_tag :content => /was not found/
+ end
+
def test_revision_with_repository_pointing_to_a_subdirectory
r = Project.find(1).repository
# Changes repository url to a subdirectory