Skip to content

Commit 2bf04af

Browse files
Sanitize base_url and directory parameters
this might be the cause of #25, at least from what it appears
1 parent 51becde commit 2bf04af

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/wayback_machine_downloader.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ class WaybackMachineDownloader
133133

134134
def initialize params
135135
validate_params(params)
136-
@base_url = params[:base_url]
136+
@base_url = params[:base_url]&.tidy_bytes
137137
@exact_url = params[:exact_url]
138138
if params[:directory]
139-
@directory = File.expand_path(params[:directory])
139+
sanitized_dir = params[:directory].tidy_bytes
140+
@directory = File.expand_path(sanitized_dir)
140141
else
141142
@directory = nil
142143
end
@@ -694,7 +695,6 @@ def download_file (file_remote_info, http)
694695
file_timestamp = file_remote_info[:timestamp]
695696

696697
# sanitize file_id to ensure it is a valid path component
697-
file_id = file_id.tidy_bytes if file_id
698698
raw_path_elements = file_id.split('/')
699699

700700
sanitized_path_elements = raw_path_elements.map do |element|

lib/wayback_machine_downloader/archive_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def get_raw_list_from_api(url, page_index, http)
2525
# Check if the response contains the header ["timestamp", "original"]
2626
json.shift if json.first == ["timestamp", "original"]
2727
json
28-
rescue JSON::ParserError, StandardError => e
28+
rescue JSON::ParserError => e
2929
warn "Failed to fetch data from API: #{e.message}"
3030
[]
3131
end

0 commit comments

Comments
 (0)