mirror of
https://github.com/meineerde/redmine.git
synced 2026-02-06 09:03:25 +00:00
Disallow all in /robots.txt if login is required (#37807).
Patch by Holger Just. git-svn-id: https://svn.redmine.org/redmine/trunk@21940 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
afbec488c4
commit
0f8c36869e
@ -27,7 +27,7 @@ class WelcomeController < ApplicationController
|
||||
end
|
||||
|
||||
def robots
|
||||
@projects = Project.visible(User.anonymous)
|
||||
@projects = Project.visible(User.anonymous) unless Setting.login_required?
|
||||
render :layout => false, :content_type => 'text/plain'
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,4 +1,7 @@
|
||||
User-agent: *
|
||||
<% if Setting.login_required? -%>
|
||||
Disallow: /
|
||||
<% else -%>
|
||||
<% @projects.each do |project| -%>
|
||||
<% [project, project.id].each do |p| -%>
|
||||
Disallow: <%= url_for(:controller => 'repositories', :action => :show, :id => p) %>
|
||||
@ -18,3 +21,4 @@ Disallow: <%= url_for(projects_path(:trailing_slash => true)) %>*.pdf$
|
||||
Disallow: <%= url_for(signin_path) %>
|
||||
Disallow: <%= url_for(register_path) %>
|
||||
Disallow: <%= url_for(lost_password_path) %>
|
||||
<% end -%>
|
||||
|
||||
@ -48,6 +48,10 @@ class WelcomeTest < Redmine::IntegrationTest
|
||||
get '/robots.txt'
|
||||
assert_response :success
|
||||
assert_equal 'text/plain', @response.media_type
|
||||
|
||||
# Disallow everything if logins are required
|
||||
assert_not @response.body.match(%r{^Disallow: /projects/ecookbook/issues\r?$})
|
||||
assert @response.body.match(%r{^Disallow: /\r?$})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user