Ensure no new line chars in envs
This commit is contained in:
@@ -14,6 +14,8 @@ module EnvironmentWriter
|
||||
def modify_env(file, name, value)
|
||||
return if value.nil?
|
||||
|
||||
raise ArgumentError, "Invalid input: #{name}=#{value}" if value.include?("\n")
|
||||
|
||||
File.open(ENV[file], "a") do |f|
|
||||
f.puts "#{name}=#{value}"
|
||||
end
|
||||
|
||||
@@ -23,6 +23,12 @@ RSpec.describe EnvironmentWriter do
|
||||
|
||||
it { expect { subject }.not_to change { File.read(ENV["GITHUB_OUTPUT"], chomp: true).last } }
|
||||
end
|
||||
|
||||
context "when value contains a newline" do
|
||||
let(:value) { "var_value\n" }
|
||||
|
||||
it { expect { subject }.to raise_error(ArgumentError) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#set_environment" do
|
||||
@@ -39,5 +45,11 @@ RSpec.describe EnvironmentWriter do
|
||||
|
||||
it { expect { subject }.not_to change { File.read(ENV["GITHUB_ENV"], chomp: true).last } }
|
||||
end
|
||||
|
||||
context "when value contains a newline" do
|
||||
let(:value) { "env_var_value\n" }
|
||||
|
||||
it { expect { subject }.to raise_error(ArgumentError) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user