mirror of
https://github.com/moebooru/moebooru
synced 2025-08-31 14:05:14 +00:00
Immediately check url scheme in lib/download.
This commit is contained in:
@@ -28,16 +28,17 @@ module Danbooru
|
||||
while true
|
||||
url = Addressable::URI.parse(source)
|
||||
url.host = url.normalized_host
|
||||
|
||||
unless url.scheme == 'http' or url.scheme == 'https'
|
||||
raise SocketError, "URL must be HTTP or HTTPS"
|
||||
end
|
||||
|
||||
# check if the request uri is not percent-encoded
|
||||
if url.request_uri.match /[^!*'();:@&=+$,\/?#\[\]ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\-_.~%]/
|
||||
url.path = Addressable::URI.encode(url.path)
|
||||
url.query = Addressable::URI.encode(url.query)
|
||||
end
|
||||
|
||||
unless url.scheme == 'http' or url.scheme == 'https'
|
||||
raise SocketError, "URL must be HTTP or HTTPS"
|
||||
end
|
||||
|
||||
unless url.port
|
||||
url.port = url.scheme == 'https' ? 443 : 80
|
||||
end
|
||||
|
Reference in New Issue
Block a user