diff options
-rw-r--r-- | app/helpers/application_helper.rb | 27 | ||||
-rw-r--r-- | config/gitlab.yml.example | 3 | ||||
-rw-r--r-- | config/initializers/1_settings.rb | 1 | ||||
-rw-r--r-- | doc/update/upgrader.md | 9 | ||||
-rw-r--r-- | spec/helpers/application_helper_spec.rb | 23 |
5 files changed, 56 insertions, 7 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5f07cdf448c..198ca76545c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -231,4 +231,31 @@ module ApplicationHelper content_tag(:i, nil, class: 'icon-spinner icon-spin') + text end end + + def link_to(name = nil, options = nil, html_options = nil, &block) + begin + uri = URI(options) + host = uri.host + absolute_uri = uri.absolute? + rescue URI::InvalidURIError, ArgumentError + host = nil + absolute_uri = nil + end + + # Add "nofollow" only to external links + if host && host != Gitlab.config.gitlab.host && absolute_uri + if html_options + if html_options[:rel] + html_options[:rel] << " nofollow" + else + html_options.merge!(rel: "nofollow") + end + else + html_options = Hash.new + html_options[:rel] = "nofollow" + end + end + + super + end end diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 04e85ed9a9d..6f33256a2b1 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -35,9 +35,6 @@ production: &base # Email address used in the "From" field in mails sent by GitLab email_from: example@example.com - # Email address of your support contact (default: same as email_from) - support_email: support@example.com - # Email server smtp settings are in [a separate file](initializers/smtp_settings.rb.sample). ## User settings diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 97f29546404..18c628223a4 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -79,7 +79,6 @@ Settings.gitlab['port'] ||= Settings.gitlab.https ? 443 : 80 Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || '' Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http" Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}" -Settings.gitlab['support_email'] ||= Settings.gitlab.email_from Settings.gitlab['url'] ||= Settings.send(:build_gitlab_url) Settings.gitlab['user'] ||= 'git' Settings.gitlab['user_home'] ||= begin diff --git a/doc/update/upgrader.md b/doc/update/upgrader.md index b3947fa2deb..19faca4ec4e 100644 --- a/doc/update/upgrader.md +++ b/doc/update/upgrader.md @@ -18,11 +18,12 @@ __GitLab Upgrader is available only for GitLab version 6.4.2 or higher__ ### 2. Run gitlab upgrade tool + # Starting with GitLab version 7.0 upgrader script has been moved to bin directory cd /home/git/gitlab - sudo -u git -H ruby bin/upgrade.rb + if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb; else sudo -u git -H ruby script/upgrade.rb; fi # to perform a non-interactive install (no user input required) you can add -y - # sudo -u git -H ruby bin/upgrade.rb -y + # if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb -y; else sudo -u git -H ruby script/upgrade.rb -y; fi ### 3. Start application @@ -55,6 +56,8 @@ Here is a one line command with step 1 to 4 for the next time you upgrade: ```bash cd /home/git/gitlab; sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production; \ - sudo service gitlab stop; sudo -u git -H ruby bin/upgrade.rb -y; sudo service gitlab start; \ + sudo service gitlab stop; \ + if [ -f bin/upgrade.rb ]; then sudo -u git -H ruby bin/upgrade.rb -y; else sudo -u git -H ruby script/upgrade.rb -y; fi; \ + sudo service gitlab start; \ sudo service nginx restart; sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production ``` diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 0376e0aadf0..10c5617d245 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -195,4 +195,27 @@ describe ApplicationHelper do simple_sanitize(input).should == a_tag end end + + describe "link_to" do + + it "should not include rel=nofollow for internal links" do + expect(link_to("Home", root_path)).to eq("<a href=\"/\">Home</a>") + end + + it "should include rel=nofollow for external links" do + expect(link_to("Example", "http://www.example.com")).to eq("<a href=\"http://www.example.com\" rel=\"nofollow\">Example</a>") + end + + it "should include re=nofollow for external links and honor existing html_options" do + expect( + link_to("Example", "http://www.example.com", class: "toggle", data: {toggle: "dropdown"}) + ).to eq("<a class=\"toggle\" data-toggle=\"dropdown\" href=\"http://www.example.com\" rel=\"nofollow\">Example</a>") + end + + it "should include rel=nofollow for external links and preserver other rel values" do + expect( + link_to("Example", "http://www.example.com", rel: "noreferrer") + ).to eq("<a href=\"http://www.example.com\" rel=\"noreferrer nofollow\">Example</a>") + end + end end |