Skip to content

Commit c433656

Browse files
committed
fix ENC 'echo' script template to prevent expansion
Currently the template script for creating the 'echo' script used for ENC data wraps the data provided by the actual ENC in `cat <<-EOF`, which causes the enclosed data to be variable-expanded, escape characters (like double backslashes) to be replaced with their concrete representations, etc. This breaks things horribly if you have (e.g.) JSON data with escaped strings (`"C:\\Windows"`), which will be processed and output without those escapes (`"C:\Windows"`), which is invalid, and definitely not what the user intended under any circumstance. Using the 'quoted' variant of shell heredocs (`cat <<-'EOF'`) stops this expansion.
1 parent 5071b97 commit c433656

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/octocatalog-diff/catalog-util/builddir.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def install_enc(logger)
207207
enc_path = File.join(@tempdir, 'enc.sh')
208208
File.open(enc_path, 'w') do |f|
209209
f.write "#!/bin/sh\n"
210-
f.write "cat <<-EOF\n"
210+
f.write "cat <<-'EOF'\n"
211211
f.write enc_obj.content
212212
f.write "\nEOF\n"
213213
end

spec/octocatalog-diff/tests/catalog-util/builddir_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,7 +796,7 @@
796796
testobj = OctocatalogDiff::CatalogUtil::BuildDir.new(options, logger)
797797
enc = File.join(testobj.tempdir, 'enc.sh')
798798
expect(File.file?(enc)).to eq(true)
799-
expect(File.read(enc)).to eq("#!/bin/sh\ncat <<-EOF\n---\n\nEOF\n")
799+
expect(File.read(enc)).to eq("#!/bin/sh\ncat <<-'EOF'\n---\n\nEOF\n")
800800
end
801801
end
802802

0 commit comments

Comments
 (0)