ndr_import 11.5.0 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c96ccb2b8ec749a6f0b14836b2ba0e9006f50016988447ffd6833471ef2386ac
4
- data.tar.gz: f0602bf4c5f5df488261792843951d4c939e7e05249ea818b0ded27172047741
3
+ metadata.gz: 0f7ea78a292f3c2ee622bda06d341329c97af0dd0edd36c039ee349a08b74284
4
+ data.tar.gz: 1dae1db120f401a1cfb85b5d243563fd9ba26f290b313d561d4b6b3327b732b8
5
5
  SHA512:
6
- metadata.gz: 0aa09835563161998d8d86165bb94346d71528dbf07ee4830ed19c1887466d2b955a583f8ad5e264ae1bc46c69b4025d844c422de391ce72ef942624721e6b62
7
- data.tar.gz: 61c1cb4a0959cdcab990f27120493fedf45e4df3c10e243a853ed77ada29374b33cc5aa0e7ab8a1a93d125e195c1e85d7881657f896c923ef80dbcea585c4a16
6
+ metadata.gz: bb20b9455c14347bd9ce894858693f94f3c7d8d3fa2c2eac390bb948011db5ae1001513ce6654cca1ca2bdbad40cf5dbd5e6c3bb491def911893159447f7fbe9
7
+ data.tar.gz: 5683e42c10156785a8e58f13269250f59f90c81ca46613840e405f6f7e6c80a7f203e3ccdb4b49fef0eeb1d300394f5120464cb5d5bd193950505f6f36365281
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ## [Unreleased]
2
+ * no unreleased changes
2
3
 
3
- *no unreleased changes*
4
+ ## 11.6.0 / 2026-09-08
5
+ ### Fixed
6
+ * `NdrImport::File::SevenZip` was extracting files one directory level too deep
7
+ * Support rubyzip 3
4
8
 
5
9
  ## 11.5.0 / 2026-06-25
6
10
  ### Fixed
@@ -46,7 +46,7 @@ module NdrImport
46
46
  next unless entry.file? && basename.match(@pattern)
47
47
 
48
48
  unzipped_filename = destination.join(basename)
49
- szr.extract([entry], unzipped_filename)
49
+ szr.extract([entry], destination)
50
50
 
51
51
  unzipped_files(unzipped_filename, &block)
52
52
  end
@@ -57,8 +57,9 @@ module NdrImport
57
57
  def metadata_from_stream(xpath)
58
58
  cursor = Cursor.new(xpath, false)
59
59
 
60
- # If markup isn't well-formed, try to work around it:
61
- options = Nokogiri::XML::ParseOptions::RECOVER
60
+ # If markup isn't well-formed, try to work around it (but keep NONET,
61
+ # so external entities/DTDs can't trigger network requests):
62
+ options = Nokogiri::XML::ParseOptions::RECOVER | Nokogiri::XML::ParseOptions::NONET
62
63
  reader = Nokogiri::XML::Reader(@stream, nil, @encoding, options)
63
64
 
64
65
  reader.each do |node|
@@ -44,7 +44,11 @@ module NdrImport
44
44
  next unless entry.file? && basename.match(@pattern)
45
45
 
46
46
  unzipped_filename = destination.join(basename)
47
- zipfile.extract(entry, unzipped_filename)
47
+ if zipfile.respond_to?(:extract_v3)
48
+ zipfile.extract_v3(entry, basename, destination_directory: destination)
49
+ else
50
+ zipfile.extract(entry, basename, destination_directory: destination)
51
+ end
48
52
 
49
53
  unzipped_files(unzipped_filename, &block)
50
54
  end
@@ -183,8 +183,9 @@ module NdrImport
183
183
  # Track nesting as the cursor moves through the document:
184
184
  cursor = Cursor.new(node_xpath, pattern_match_xpath)
185
185
 
186
- # If markup isn't well-formed, try to work around it:
187
- options = Nokogiri::XML::ParseOptions::RECOVER
186
+ # If markup isn't well-formed, try to work around it (but keep NONET,
187
+ # so external entities/DTDs can't trigger network requests):
188
+ options = Nokogiri::XML::ParseOptions::RECOVER | Nokogiri::XML::ParseOptions::NONET
188
189
  reader = Nokogiri::XML::Reader(io, nil, encoding, options)
189
190
 
190
191
  reader.each do |node|
@@ -9,13 +9,13 @@ module NdrImport
9
9
 
10
10
  # Unzip the file, creating the destination directory if necessary.
11
11
  # A pattern can be provided to only extract required files.
12
- def unzip_file(source, destination, pattern = //)
12
+ def unzip_file(source, destination, pattern = //) # rubocop:disable Metrics/MethodLength
13
13
  # SECURE TVB Mon Aug 13 14:41:05 BST 2012 : SafePath will raise exception if insecure
14
14
  # path is constructed
15
15
  # SafeFile.safepath_to_string will make sure that the arguments are from type SafePath
16
16
 
17
17
  # SECURE: BNS 2010-09-21 (for external access)
18
- fail 'Not allowed in external environment' if defined?(::Rails) && ::Rails.env.external?
18
+ raise 'Not allowed in external environment' if defined?(::Rails) && ::Rails.env.external? # rubocop:disable Rails/UnknownEnv
19
19
 
20
20
  require 'zip'
21
21
  # TODO: Abort if destination directory already exists...
@@ -25,18 +25,21 @@ module NdrImport
25
25
  zipfile.entries.each do |entry|
26
26
  # SECURE: TPG 2010-11-1: The path is stripped from the zipfile entry when extracted
27
27
  basename = ::File.basename(entry.name)
28
- zipfile.extract(entry, destination.join(basename)) if entry.file? && basename.match(pattern)
28
+ if entry.file? && basename.match(pattern)
29
+ if zipfile.respond_to?(:extract_v3)
30
+ zipfile.extract_v3(entry, basename, destination_directory: destination)
31
+ else
32
+ zipfile.extract(entry, basename, destination_directory: destination)
33
+ end
34
+ end
29
35
  end
30
36
  end
31
-
32
- rescue ::Zip::ZipDestinationFileExistsError
37
+ rescue (defined?(::Zip::ZipDestinationFileExistsError) ? ::Zip::ZipDestinationFileExistsError : ::Zip::DestinationExistsError)
33
38
  # I'm going to ignore this and just overwrite the files.
34
- rescue SecurityError => ex
35
- raise ex
36
- rescue ArgumentError => ex
37
- raise ex
38
- rescue => ex
39
- puts ex
39
+ rescue ArgumentError, SecurityError => e
40
+ raise e
41
+ rescue StandardError => e
42
+ puts e # rubocop:disable Rails/Output
40
43
  end
41
44
  end
42
45
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # This stores the current version of the NdrImport gem
3
3
  module NdrImport
4
- VERSION = '11.5.0'
4
+ VERSION = '11.6.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ndr_import
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.5.0
4
+ version: 11.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - NCRS Development Team
8
- autorequire:
9
8
  bindir: exe
10
9
  cert_chain: []
11
- date: 2026-06-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activemodel
@@ -65,33 +64,45 @@ dependencies:
65
64
  - !ruby/object:Gem::Version
66
65
  version: '6'
67
66
  - !ruby/object:Gem::Dependency
68
- name: rubyzip
67
+ name: roo
69
68
  requirement: !ruby/object:Gem::Requirement
70
69
  requirements:
71
- - - "~>"
70
+ - - ">="
72
71
  - !ruby/object:Gem::Version
73
72
  version: '2.0'
73
+ - - "<"
74
+ - !ruby/object:Gem::Version
75
+ version: '4'
74
76
  type: :runtime
75
77
  prerelease: false
76
78
  version_requirements: !ruby/object:Gem::Requirement
77
79
  requirements:
78
- - - "~>"
80
+ - - ">="
79
81
  - !ruby/object:Gem::Version
80
82
  version: '2.0'
83
+ - - "<"
84
+ - !ruby/object:Gem::Version
85
+ version: '4'
81
86
  - !ruby/object:Gem::Dependency
82
- name: roo
87
+ name: rubyzip
83
88
  requirement: !ruby/object:Gem::Requirement
84
89
  requirements:
85
- - - "~>"
90
+ - - ">="
86
91
  - !ruby/object:Gem::Version
87
92
  version: '2.0'
93
+ - - "<"
94
+ - !ruby/object:Gem::Version
95
+ version: '4'
88
96
  type: :runtime
89
97
  prerelease: false
90
98
  version_requirements: !ruby/object:Gem::Requirement
91
99
  requirements:
92
- - - "~>"
100
+ - - ">="
93
101
  - !ruby/object:Gem::Version
94
102
  version: '2.0'
103
+ - - "<"
104
+ - !ruby/object:Gem::Version
105
+ version: '4'
95
106
  - !ruby/object:Gem::Dependency
96
107
  name: avro
97
108
  requirement: !ruby/object:Gem::Requirement
@@ -242,16 +253,22 @@ dependencies:
242
253
  name: spreadsheet
243
254
  requirement: !ruby/object:Gem::Requirement
244
255
  requirements:
245
- - - '='
256
+ - - ">="
246
257
  - !ruby/object:Gem::Version
247
258
  version: 1.2.6
259
+ - - "<"
260
+ - !ruby/object:Gem::Version
261
+ version: '1.4'
248
262
  type: :runtime
249
263
  prerelease: false
250
264
  version_requirements: !ruby/object:Gem::Requirement
251
265
  requirements:
252
- - - '='
266
+ - - ">="
253
267
  - !ruby/object:Gem::Version
254
268
  version: 1.2.6
269
+ - - "<"
270
+ - !ruby/object:Gem::Version
271
+ version: '1.4'
255
272
  - !ruby/object:Gem::Dependency
256
273
  name: bundler
257
274
  requirement: !ruby/object:Gem::Requirement
@@ -465,7 +482,6 @@ homepage: https://github.com/NHSDigital/ndr_import
465
482
  licenses:
466
483
  - MIT
467
484
  metadata: {}
468
- post_install_message:
469
485
  rdoc_options: []
470
486
  require_paths:
471
487
  - lib
@@ -480,8 +496,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
480
496
  - !ruby/object:Gem::Version
481
497
  version: '0'
482
498
  requirements: []
483
- rubygems_version: 3.5.22
484
- signing_key:
499
+ rubygems_version: 3.6.9
485
500
  specification_version: 4
486
501
  summary: NDR Import
487
502
  test_files: []