mirror of
https://github.com/StrawberryMaster/wayback-machine-downloader.git
synced 2025-12-17 17:56:44 +00:00
Sanitize base_url and directory parameters
this might be the cause of #25, at least from what it appears
This commit is contained in:
parent
51becde916
commit
2bf04aff48
@ -133,10 +133,11 @@ class WaybackMachineDownloader
|
||||
|
||||
def initialize params
|
||||
validate_params(params)
|
||||
@base_url = params[:base_url]
|
||||
@base_url = params[:base_url]&.tidy_bytes
|
||||
@exact_url = params[:exact_url]
|
||||
if params[:directory]
|
||||
@directory = File.expand_path(params[:directory])
|
||||
sanitized_dir = params[:directory].tidy_bytes
|
||||
@directory = File.expand_path(sanitized_dir)
|
||||
else
|
||||
@directory = nil
|
||||
end
|
||||
@ -694,7 +695,6 @@ class WaybackMachineDownloader
|
||||
file_timestamp = file_remote_info[:timestamp]
|
||||
|
||||
# sanitize file_id to ensure it is a valid path component
|
||||
file_id = file_id.tidy_bytes if file_id
|
||||
raw_path_elements = file_id.split('/')
|
||||
|
||||
sanitized_path_elements = raw_path_elements.map do |element|
|
||||
|
||||
@ -25,7 +25,7 @@ module ArchiveAPI
|
||||
# Check if the response contains the header ["timestamp", "original"]
|
||||
json.shift if json.first == ["timestamp", "original"]
|
||||
json
|
||||
rescue JSON::ParserError, StandardError => e
|
||||
rescue JSON::ParserError => e
|
||||
warn "Failed to fetch data from API: #{e.message}"
|
||||
[]
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user