Security fixes for download-3rd-party.rb
This commit is contained in:
parent
8d5448601b
commit
1c27220f59
@ -70,7 +70,7 @@ Jekyll::Hooks.register :site, :after_init do |site|
|
|||||||
unless File.file?(dest)
|
unless File.file?(dest)
|
||||||
puts "Downloading #{url} to #{dest}"
|
puts "Downloading #{url} to #{dest}"
|
||||||
File.open(dest, "wb") do |saved_file|
|
File.open(dest, "wb") do |saved_file|
|
||||||
URI.open(url, "rb") do |read_file|
|
URI(url).open("rb") do |read_file|
|
||||||
saved_file.write(read_file.read)
|
saved_file.write(read_file.read)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -148,7 +148,7 @@ Jekyll::Hooks.register :site, :after_init do |site|
|
|||||||
puts "Downloading fonts from #{url} to #{dest}"
|
puts "Downloading fonts from #{url} to #{dest}"
|
||||||
# download the css file with a fake user agent to force downloading woff2 fonts instead of ttf
|
# download the css file with a fake user agent to force downloading woff2 fonts instead of ttf
|
||||||
# user agent from https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
|
# user agent from https://www.whatismybrowser.com/guides/the-latest-user-agent/chrome
|
||||||
doc = Nokogiri::HTML(URI.open(url, "User-Agent" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"))
|
doc = Nokogiri::HTML(URI(url).open("User-Agent" => "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36"))
|
||||||
css = CssParser::Parser.new
|
css = CssParser::Parser.new
|
||||||
css.load_string! doc.document.text
|
css.load_string! doc.document.text
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user