kataba 1.1.0 → 1.1.1
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 +4 -4
- data/lib/kataba/fetcher.rb +22 -1
- data/lib/kataba.rb +3 -1
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 701caff7f874cbe1f9a02c4d30e58576e3c9970aba61cef220ac96460b729f9c
|
|
4
|
+
data.tar.gz: 803f46524665ca8f9d0e1ee82dfa154dee798363a2326195feeb54ef412e26b5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b323b6a3742abfba45ebf1dd98345c73f5e7b703229b9a7f852069a616e2b7cac26db91e9d23f71b5495878108bad8bb71d0e765ea5a4c7f8ce7b8415349ecb
|
|
7
|
+
data.tar.gz: e653e7a40a363a9d4b174d84ebc5e3907edc0a05c8c9a13231688d86ed033e6c0c38ff26f84ac8d58c6b97fb4eb22fa70897a2b29aaf774164e20a1a31ac4741
|
data/lib/kataba/fetcher.rb
CHANGED
|
@@ -12,6 +12,12 @@ module Kataba
|
|
|
12
12
|
# consumer already trusted this host by putting it in their
|
|
13
13
|
# schemaLocation. Cross-origin downgrades stay refused — that's
|
|
14
14
|
# the actual DNS-redirect attack vector.
|
|
15
|
+
# - /mods/xml.xsd: rewrite to /standards/mods/xml.xsd before the
|
|
16
|
+
# first request. The /mods/xml.xsd path is what every mods-3-N.xsd
|
|
17
|
+
# embeds in its xs:import, but LoC only serves the file from
|
|
18
|
+
# /standards/mods/xml.xsd today — the embedded path bounces
|
|
19
|
+
# HTTPS->HTTP and 503s. Applied here so transitive xs:import
|
|
20
|
+
# resolution benefits, not just top-level fetch_schema calls.
|
|
15
21
|
#
|
|
16
22
|
# mirror_list remains the consumer's backstop for URI-identity
|
|
17
23
|
# changes (path renames, host moves) that no delivery heuristic
|
|
@@ -19,6 +25,13 @@ module Kataba
|
|
|
19
25
|
class Fetcher
|
|
20
26
|
MAX_REDIRECTS = 5
|
|
21
27
|
|
|
28
|
+
# Map from a path that's embedded in published schemas but no longer
|
|
29
|
+
# serves the file, to the path that does. xml.xsd: every mods-3-N.xsd
|
|
30
|
+
# imports /mods/xml.xsd, but only /standards/mods/xml.xsd serves it.
|
|
31
|
+
PATH_REWRITES = {
|
|
32
|
+
'/mods/xml.xsd' => '/standards/mods/xml.xsd',
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
22
35
|
class FetchError < StandardError; end
|
|
23
36
|
|
|
24
37
|
def initialize(uri)
|
|
@@ -26,11 +39,19 @@ module Kataba
|
|
|
26
39
|
end
|
|
27
40
|
|
|
28
41
|
def fetch
|
|
29
|
-
attempt(@original_uri, alt_scheme_retry: true)
|
|
42
|
+
attempt(normalize(@original_uri), alt_scheme_retry: true)
|
|
30
43
|
end
|
|
31
44
|
|
|
32
45
|
private
|
|
33
46
|
|
|
47
|
+
def normalize(uri)
|
|
48
|
+
PATH_REWRITES.each do |from, to|
|
|
49
|
+
rewritten = uri.sub(%r{(\Ahttps?://[^/]+)#{Regexp.escape(from)}\z}i, "\\1#{to}")
|
|
50
|
+
return rewritten unless rewritten == uri
|
|
51
|
+
end
|
|
52
|
+
uri
|
|
53
|
+
end
|
|
54
|
+
|
|
34
55
|
def attempt(uri, alt_scheme_retry:)
|
|
35
56
|
response = request_with_redirects(uri, redirect_depth: 0)
|
|
36
57
|
|
data/lib/kataba.rb
CHANGED
|
@@ -115,7 +115,9 @@ module Kataba
|
|
|
115
115
|
# orphaned 0-byte .part on disk — the file simply isn't created.
|
|
116
116
|
fetch_uri = xsd_uri
|
|
117
117
|
if !self.configuration.mirror_list.to_s.empty?
|
|
118
|
-
|
|
118
|
+
# YAML.load_file returns nil for a comments-only or empty file.
|
|
119
|
+
# Treat that as "no mirror configured" rather than NoMethodError.
|
|
120
|
+
mirror_list = YAML.load_file(self.configuration.mirror_list) || {}
|
|
119
121
|
mirror = mirror_list[xsd_uri]
|
|
120
122
|
fetch_uri = mirror unless mirror.to_s.empty?
|
|
121
123
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kataba
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Cliff
|
|
@@ -14,56 +14,56 @@ dependencies:
|
|
|
14
14
|
name: nokogiri
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- -
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: '1.19'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- -
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '1.19'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: minitest
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- -
|
|
45
|
+
- - ">="
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- -
|
|
52
|
+
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: webmock
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- -
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
61
|
version: '0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- -
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
69
|
description: Kataba allows for mirroring and offline storage of XSD files, to enhance
|
|
@@ -85,16 +85,16 @@ require_paths:
|
|
|
85
85
|
- lib
|
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
|
88
|
-
- -
|
|
88
|
+
- - ">="
|
|
89
89
|
- !ruby/object:Gem::Version
|
|
90
90
|
version: '3.2'
|
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
requirements:
|
|
93
|
-
- -
|
|
93
|
+
- - ">="
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
rubygems_version: 3.
|
|
97
|
+
rubygems_version: 3.4.10
|
|
98
98
|
signing_key:
|
|
99
99
|
specification_version: 4
|
|
100
100
|
summary: XML Schema Definition (XSD) mirroring and offline validation for Nokogiri
|