From c7ef689d86294bcdb8ae5d31ddabcba416e3382d Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Wed, 28 Sep 2022 13:51:54 -0700 Subject: [PATCH] Prevent trailing space character on user agent --- lib/vagrant/util/downloader.rb | 2 +- test/unit/vagrant/util/downloader_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/downloader.rb b/lib/vagrant/util/downloader.rb index eee9744e7..a7daf9684 100644 --- a/lib/vagrant/util/downloader.rb +++ b/lib/vagrant/util/downloader.rb @@ -21,7 +21,7 @@ module Vagrant # are properly tracked. # # Vagrant/1.7.4 (+https://www.vagrantup.com; ruby2.1.0) - USER_AGENT = "Vagrant/#{VERSION} (+https://www.vagrantup.com; #{RUBY_ENGINE}#{RUBY_VERSION}) #{ENV['VAGRANT_USER_AGENT_PROVISIONAL_STRING']}".freeze + USER_AGENT = "Vagrant/#{VERSION} (+https://www.vagrantup.com; #{RUBY_ENGINE}#{RUBY_VERSION}) #{ENV['VAGRANT_USER_AGENT_PROVISIONAL_STRING']}".strip.freeze # Hosts that do not require notification on redirect SILENCED_HOSTS = [ diff --git a/test/unit/vagrant/util/downloader_test.rb b/test/unit/vagrant/util/downloader_test.rb index ac69cc7e1..b7c155b1d 100644 --- a/test/unit/vagrant/util/downloader_test.rb +++ b/test/unit/vagrant/util/downloader_test.rb @@ -22,6 +22,12 @@ describe Vagrant::Util::Downloader do allow(Vagrant).to receive(:in_installer?).and_return(false) end + describe "USER_AGENT" do + it "should not include a trailing space" do + expect(described_class.const_get(:USER_AGENT)).not_to end_with(" ") + end + end + describe "#download!" do let(:curl_options) { ["-q", "--fail", "--location", "--max-redirs", "10",