Skip to content

Commit 06ca08c

Browse files
authored
Fixed security issue with download 3rd party plugin (cotes2020#2365)
Added condition to avoid security issue according to GitHub's dependabot ![image](https://github.com/alshedivat/al-folio/assets/31376482/b470a83a-5038-48be-99a6-1cbf63de57bf) --------- Signed-off-by: George Araujo <[email protected]>
1 parent b315315 commit 06ca08c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

_plugins/download-3rd-party.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
require 'uri'
88

99
def download_file(url, dest)
10+
# only try to download the file if url doesn't start with | for security reasons
11+
if url.start_with?('|')
12+
return
13+
end
14+
1015
# create the directory if it doesn't exist
1116
dir = File.dirname(dest)
1217
unless File.directory?(dir)
@@ -30,11 +35,16 @@ def download_file(url, dest)
3035
end
3136

3237
def download_fonts(url, dest)
38+
# only try to download the file if url doesn't start with | for security reasons
39+
if url.start_with?('|')
40+
return
41+
end
42+
3343
# only download fonts if the directory doesn't exist or is empty
3444
unless File.directory?(dest) && !Dir.empty?(dest)
3545
puts "Downloading fonts from #{url} to #{dest}"
3646
# get available fonts from the url
37-
doc = Nokogiri::HTML(URI().open(url, "User-Agent" => "Ruby/#{RUBY_VERSION}"))
47+
doc = Nokogiri::HTML(URI.open(url, "User-Agent" => "Ruby/#{RUBY_VERSION}"))
3848
doc.css('a').each do |link|
3949
# get the file name from the url
4050
file_name = link['href'].split('/').last.split('?').first
@@ -49,6 +59,11 @@ def download_fonts(url, dest)
4959
end
5060

5161
def download_fonts_from_css(config, url, dest)
62+
# only try to download the file if url doesn't start with | for security reasons
63+
if url.start_with?('|')
64+
return
65+
end
66+
5267
# get the file name from the url
5368
file_name = url.split('/').last.split('?').first
5469

0 commit comments

Comments
 (0)