Skip to content

Commit 9b3b903

Browse files
committed
Rely on latest stdlib for proper powershell escaping
1 parent 0216d9a commit 9b3b903

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

lib/puppet/parser/functions/docker_run_flags.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module Puppet::Parser::Functions
99
subject = args[0]
1010

1111
if self['facts'] && self['facts']['os']['family'] == 'windows'
12-
%("#{subject.gsub('"', '\\"')}")
12+
call_function('powershell_escape', subject)
1313
else
1414
subject.shellescape
1515
end

metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"dependencies": [
1111
{
1212
"name": "puppetlabs/stdlib",
13-
"version_requirement": ">= 4.24.0 < 9.0.0"
13+
"version_requirement": ">= 8.2.0 < 9.0.0"
1414
},
1515
{
1616
"name": "puppetlabs/apt",

spec/unit/lib/puppet/parser/functions/docker_run_flags_spec.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
require 'spec_helper'
22

33
describe 'the "docker_run_flags" parser function' do
4+
before :each do
5+
Puppet[:modulepath] = "spec/fixtures/modules/"
6+
end
7+
48
let :scope do
59
node = Puppet::Node.new('localhost')
610
compiler = Puppet::Parser::Compiler.new(node)
@@ -22,7 +26,7 @@
2226
let(:os_family) { 'windows' }
2327

2428
it 'escapes special chars' do
25-
expect(scope.function_docker_run_flags([{ 'env' => [%.MYSQL_PASSWORD='"$()[]{}<>.], 'extra_params' => [] }])).to eq(%^-e "MYSQL_PASSWORD='\\"$()[]{}<>" \\\n^)
29+
expect(scope.function_docker_run_flags([{ 'env' => [%.MYSQL_PASSWORD='"$()[]{}<>.], 'extra_params' => [] }])).to eq(%^-e MYSQL_PASSWORD=`'\\`"`$()[]{}<> \\\n^)
2630
end
2731
end
2832
end

0 commit comments

Comments
 (0)