diff --git a/lib/fpm/package/rpm.rb b/lib/fpm/package/rpm.rb index 238d47568..6ab939f32 100644 --- a/lib/fpm/package/rpm.rb +++ b/lib/fpm/package/rpm.rb @@ -199,8 +199,8 @@ class FPM::Package::RPM < FPM::Package # If and only if any of the above are done, then also replace ' with \', " with \", and \ with \\\\ # to accommodate escape and quote processing that rpm will perform in that case (but not otherwise) def rpm_fix_name(name) - if name.match?(/[ \t*?%$\[\]]/) - name = name.gsub(/(\ |\t|\[|\]|\*|\?|\%|\$|'|"|\\)/, { + if name.match?(/[ \t*?%${}\[\]]/) + name = name.gsub(/(\ |\t|\[|\]|\*|\?|\%|\$|'|"|\{|\}|\\)/, { ' ' => '?', "\t" => '?', '%' => '[%]', @@ -209,6 +209,8 @@ def rpm_fix_name(name) '*' => '[*]', '[' => '[\[]', ']' => '[\]]', + '{' => '[\{]', + '}' => '[\}]', '"' => '\\"', "'" => "\\'", '\\' => '\\\\\\\\', diff --git a/spec/fpm/package/rpm_spec.rb b/spec/fpm/package/rpm_spec.rb index 015a801f4..bc43013b2 100644 --- a/spec/fpm/package/rpm_spec.rb +++ b/spec/fpm/package/rpm_spec.rb @@ -569,6 +569,15 @@ def subject.render_template; @rpmspec = template("rpm.erb").result(binding); end insist { rpm.files } == [ "/example/%name%" ] end + it "should escape '{' and '}' characters in filenames" do + Dir.mkdir(subject.staging_path("/example")) + File.write(subject.staging_path("/example/{{ test }}"), "Hello") + subject.output(@target) + + rpm = ::RPM::File.new(@target) + insist { rpm.files } == [ "/example/{{ test }}" ] + end + it "should correctly include files with spaces and quotation marks" do names = [ "/It's time to go.txt",