wayback_machine_downloader_straw 2.4.9 → 2.5.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b8fee9861e93b51713311686022ec251db82148f071d8f8a9dc697dec67ccba
|
|
4
|
+
data.tar.gz: 2046e2f70156b107bb5c9f4d14eff5d1aab93b9c37be20ef8c88191ba6218447
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21a807f64af7eadc35b7c964124ff2c77455199313baa1d8379e99885f25788c370552e1b04202c743d924bb52c481d99367d8a570586fba9277088c41312720
|
|
7
|
+
data.tar.gz: 66f4dd29392ccc379f5747c2292afb3cef0836df7337910e2e060f5f06f4968de33b9975600ac51bb168739985d13066f13e66a9c949bd7a0439735f07cffb88
|
|
@@ -104,7 +104,7 @@ module ArchiveAPI
|
|
|
104
104
|
body = response.body.to_s.strip
|
|
105
105
|
else
|
|
106
106
|
request = Net::HTTP::Get.new(request_url)
|
|
107
|
-
request["User-Agent"] = "wmd-straw/#{WaybackMachineDownloader::VERSION rescue '2.
|
|
107
|
+
request["User-Agent"] = "wmd-straw/#{WaybackMachineDownloader::VERSION rescue '2.5.0'}"
|
|
108
108
|
request["Connection"] = "keep-alive"
|
|
109
109
|
request["Accept-Encoding"] = "gzip, deflate"
|
|
110
110
|
response = http.request(request)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'cgi'
|
|
2
|
+
|
|
1
3
|
module PageRequisites
|
|
2
4
|
# regex to find links in href, src, url(), and srcset
|
|
3
5
|
# this ignores data: URIs, mailto:, and anchors
|
|
@@ -17,6 +19,7 @@ module PageRequisites
|
|
|
17
19
|
attribute, attr_url, css_url, srcset_url = match
|
|
18
20
|
url = attr_url || css_url || srcset_url
|
|
19
21
|
next unless url
|
|
22
|
+
url = CGI.unescapeHTML(url).strip
|
|
20
23
|
|
|
21
24
|
# href is also used for navigation. Do not turn links to server-rendered
|
|
22
25
|
# pages into prerequisite CDX lookups; doing so can multiply API traffic
|
|
@@ -40,7 +43,7 @@ module PageRequisites
|
|
|
40
43
|
def self.page_url?(url)
|
|
41
44
|
path = begin
|
|
42
45
|
URI.parse(url).path
|
|
43
|
-
rescue URI::
|
|
46
|
+
rescue URI::Error
|
|
44
47
|
url.to_s.split(/[?#]/, 2).first
|
|
45
48
|
end
|
|
46
49
|
|
|
@@ -49,8 +52,9 @@ module PageRequisites
|
|
|
49
52
|
end
|
|
50
53
|
|
|
51
54
|
def self.valid_asset?(url)
|
|
52
|
-
|
|
53
|
-
return false if url.
|
|
55
|
+
url = url.to_s.strip
|
|
56
|
+
return false if url.empty?
|
|
57
|
+
return false if url.match?(/\A(?:data|mailto|javascript):/i) || url.start_with?('#')
|
|
54
58
|
true
|
|
55
59
|
end
|
|
56
60
|
end
|
|
@@ -13,26 +13,26 @@ module URLRewrite
|
|
|
13
13
|
target_host = current_host
|
|
14
14
|
|
|
15
15
|
# rewrite URLs to relative paths
|
|
16
|
-
content = content.gsub(/(\s(?:href|src|action|data-src|data-url)=["'])https?:\/\/web\.archive\.org\/web\/\d+[a-z_]*\/https?:\/\/[^\/"']+(\/[^"']*)?(["'])/i) do
|
|
17
|
-
prefix, path, suffix = $1,
|
|
16
|
+
content = content.gsub(/(\s(?:href|src|action|data-src|data-url)=["'])([ \t\r\n]*)https?:\/\/web\.archive\.org\/web\/\d+[a-z_]*\/https?:\/\/[^\/"'\s]+(\/[^"'\s]*)?([ \t\r\n]*)(["'])/i) do
|
|
17
|
+
prefix, leading_space, path, trailing_space, suffix = $1, $2, ($3 || "/index.html"), $4, $5
|
|
18
18
|
local = normalize_path_for_local(path, root_prefix)
|
|
19
|
-
"#{prefix}#{local}#{suffix}"
|
|
19
|
+
"#{prefix}#{leading_space}#{local}#{trailing_space}#{suffix}"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
# rewrite absolute URLs to same domain as relative
|
|
23
23
|
if target_host && !target_host.empty?
|
|
24
|
-
content = content.gsub(/(\s(?:href|src|action|data-src|data-url)=["'])https?:\/\/#{Regexp.escape(target_host)}(?::\d+)?(\/[^"']*)?(["'])/i) do
|
|
25
|
-
prefix, path, suffix = $1,
|
|
24
|
+
content = content.gsub(/(\s(?:href|src|action|data-src|data-url)=["'])([ \t\r\n]*)https?:\/\/#{Regexp.escape(target_host)}(?::\d+)?(\/[^"'\s]*)?([ \t\r\n]*)(["'])/i) do
|
|
25
|
+
prefix, leading_space, path, trailing_space, suffix = $1, $2, ($3 || "/index.html"), $4, $5
|
|
26
26
|
local = normalize_path_for_local(path, root_prefix)
|
|
27
|
-
"#{prefix}#{local}#{suffix}"
|
|
27
|
+
"#{prefix}#{leading_space}#{local}#{trailing_space}#{suffix}"
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
# rewrite root-relative URLs
|
|
32
|
-
content = content.gsub(/(\s(?:href|src|action|data-src|data-url)=["'])\/([^"'
|
|
33
|
-
prefix, path, suffix = $1, $2, $3
|
|
32
|
+
content = content.gsub(/(\s(?:href|src|action|data-src|data-url)=["'])([ \t\r\n]*)\/([^"'\/\s][^"'\s]*?)([ \t\r\n]*)(["'])/i) do
|
|
33
|
+
prefix, leading_space, path, trailing_space, suffix = $1, $2, $3, $4, $5
|
|
34
34
|
local = normalize_path_for_local("/#{path}", root_prefix)
|
|
35
|
-
"#{prefix}#{local}#{suffix}"
|
|
35
|
+
"#{prefix}#{leading_space}#{local}#{trailing_space}#{suffix}"
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
content
|
|
@@ -69,10 +69,10 @@ module URLRewrite
|
|
|
69
69
|
|
|
70
70
|
def rewrite_js_urls(content, root_prefix = './')
|
|
71
71
|
# rewrite archive.org URLs in JavaScript strings
|
|
72
|
-
content.gsub(/(["'])https?:\/\/web\.archive\.org\/web\/\d+[a-z_]*\/https?:\/\/[^\/"']+(\/[^"']*)?(["'])/i) do
|
|
73
|
-
quote_start, path, quote_end = $1,
|
|
72
|
+
content.gsub(/(["'])([ \t\r\n]*)https?:\/\/web\.archive\.org\/web\/\d+[a-z_]*\/https?:\/\/[^\/"'\s]+(\/[^"'\s]*)?([ \t\r\n]*)(["'])/i) do
|
|
73
|
+
quote_start, leading_space, path, trailing_space, quote_end = $1, $2, ($3 || "/index.html"), $4, $5
|
|
74
74
|
local = normalize_path_for_local(path, root_prefix)
|
|
75
|
-
"#{quote_start}#{local}#{quote_end}"
|
|
75
|
+
"#{quote_start}#{leading_space}#{local}#{trailing_space}#{quote_end}"
|
|
76
76
|
end
|
|
77
77
|
end
|
|
78
78
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wayback_machine_downloader_straw
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- strawberrymaster
|
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '0'
|
|
96
96
|
requirements: []
|
|
97
|
-
rubygems_version: 4.0.
|
|
97
|
+
rubygems_version: 4.0.20
|
|
98
98
|
specification_version: 4
|
|
99
99
|
summary: Download an entire website from the Wayback Machine.
|
|
100
100
|
test_files: []
|