r-train 0.10.3 → 0.10.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6916554d58ef01bd5484721a401f17bad17cfb4d
4
- data.tar.gz: 954215659b584ce9e2c7bdcf9be79afd73f83916
3
+ metadata.gz: 2d69879f6efb3b134ed37106668927425fa61faf
4
+ data.tar.gz: 0d6b28c005b416325c844cb5c6fe0951ef295a45
5
5
  SHA512:
6
- metadata.gz: df35a74c3535cdb75ecb1d8e525e5ba56e0430d46b67021fdca3b55e7b3263ce06251f6eebd5d7c3c2924637452c74373de645382aa1bebaa35e5461235b3f68
7
- data.tar.gz: 784104525a498146eb28cfa23a2e04e67028255f9391970335698cd3501775b32c5179ec4826fc2edc7c4892aef9fa1934f0e73e3db245f9da4c631aed692817
6
+ metadata.gz: 7835e5f36f0bc6775b72fee8de73342868d4e6dc6a6a17d52456c6b3f310a3c296e87c0a5d57e74be2c18522ed7a70a3d7e82356bc878b85b7b61c12e5555b6d
7
+ data.tar.gz: 09f2f66a0ce30ddc229640e8ae2a1c0c293317d8e6756a5486c2607eb2677355bc6105e9b5c887b7ce5b7827996e1994504fc76d3936e5058d0eeb3a28fe324b
data/CHANGELOG.md CHANGED
@@ -1,7 +1,14 @@
1
1
  # Change Log
2
2
 
3
- ## [0.10.3](https://github.com/chef/train/tree/0.10.3) (2016-03-07)
4
- [Full Changelog](https://github.com/chef/train/compare/v0.10.1...0.10.3)
3
+ ## [0.10.4](https://github.com/chef/train/tree/0.10.4) (2016-03-31)
4
+ [Full Changelog](https://github.com/chef/train/compare/v0.10.3...0.10.4)
5
+
6
+ **Fixed bugs:**
7
+
8
+ - bugfix: do not use unix path escape for windows [\#79](https://github.com/chef/train/pull/79) ([chris-rock](https://github.com/chris-rock))
9
+
10
+ ## [v0.10.3](https://github.com/chef/train/tree/v0.10.3) (2016-03-07)
11
+ [Full Changelog](https://github.com/chef/train/compare/v0.10.1...v0.10.3)
5
12
 
6
13
  **Fixed bugs:**
7
14
 
@@ -10,6 +17,7 @@
10
17
 
11
18
  **Merged pull requests:**
12
19
 
20
+ - 0.10.3 [\#78](https://github.com/chef/train/pull/78) ([chris-rock](https://github.com/chris-rock))
13
21
  - 0.10.2 [\#76](https://github.com/chef/train/pull/76) ([arlimus](https://github.com/arlimus))
14
22
 
15
23
  ## [v0.10.1](https://github.com/chef/train/tree/v0.10.1) (2016-02-29)
@@ -14,13 +14,21 @@ module Train::Extras
14
14
  def initialize(backend, path)
15
15
  @backend = backend
16
16
  @path = path
17
- @spath = Shellwords.escape(@path)
17
+ @spath = sanitize_filename(@path)
18
18
  end
19
19
 
20
20
  def basename(suffix = nil, sep = '\\')
21
21
  super(suffix, sep)
22
22
  end
23
23
 
24
+ # Ensures we do not use invalid characters for file names
25
+ # @see https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions
26
+ def sanitize_filename(filename)
27
+ return if filename.nil?
28
+ # we do not filter :, backslash and forward slash, since they are part of the path
29
+ filename.gsub(/[<>"|?*]/, '')
30
+ end
31
+
24
32
  def content
25
33
  return @content if defined?(@content)
26
34
  @content = @backend.run_command(
data/lib/train/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # Author:: Dominik Richter (<dominik.richter@gmail.com>)
4
4
 
5
5
  module Train
6
- VERSION = '0.10.3'.freeze
6
+ VERSION = '0.10.4'.freeze
7
7
  end
@@ -19,11 +19,26 @@ describe 'file common' do
19
19
  cls.new(backend, 'C:\dir\file').basename.must_equal 'file'
20
20
  end
21
21
 
22
+ it 'provides the full path with whitespace' do
23
+ wf = cls.new(backend, 'C:\Program Files\file name')
24
+ wf.path.must_equal 'C:\Program Files\file name'
25
+ wf.basename.must_equal 'file name'
26
+ end
27
+
22
28
  it 'reads file contents' do
23
29
  out = rand.to_s
24
30
  backend.mock_command('Get-Content("path") | Out-String', out)
25
31
  cls.new(backend, 'path').content.must_equal out
26
32
  end
27
33
 
34
+ it 'check escaping of invalid chars in path' do
35
+ wf = cls.new(nil, nil)
36
+ wf.sanitize_filename('c:/test') .must_equal 'c:/test'
37
+ wf.sanitize_filename('c:/test directory') .must_equal 'c:/test directory'
38
+ %w{ < > " * ?}.each do |char|
39
+ wf.sanitize_filename("c:/test#{char}directory") .must_equal 'c:/testdirectory'
40
+ end
41
+ end
42
+
28
43
  # TODO: add all missing file tests!!
29
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r-train
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.3
4
+ version: 0.10.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominik Richter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-07 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  version: '0'
239
239
  requirements: []
240
240
  rubyforge_project:
241
- rubygems_version: 2.4.6
241
+ rubygems_version: 2.5.1
242
242
  signing_key:
243
243
  specification_version: 4
244
244
  summary: Transport interface to talk to different backends.