[UploadWhitelist] Make upload whitelist case insensitive (#651)

This commit is contained in:
Donovan Daniels 2024-06-27 17:27:08 -05:00 committed by GitHub
parent ea8c7d79ff
commit 165cd315e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 2 deletions

View File

@ -1307,6 +1307,7 @@ Rails/OutputSafety:
- 'app/views/users/custom_style.css.erb'
- 'app/views/users/edit.html.erb'
- 'app/views/users/home.html.erb'
- 'app/views/upload_whitelists/_form.html.erb'
# Offense count: 9
# This cop supports unsafe autocorrection (--autocorrect-all).

View File

@ -66,7 +66,7 @@ class UploadWhitelist < ApplicationRecord
end
entries.each do |x|
if File.fnmatch?(x.pattern, url)
if File.fnmatch?(x.pattern, url, File::FNM_CASEFOLD)
return [x.allowed, x.reason]
end
end

View File

@ -1,7 +1,7 @@
<%= custom_form_for(@whitelist) do |f| %>
<%= error_messages_for "whitelist" %>
<%= f.input :pattern, label: "Pattern", as: :string %>
<%= f.input :pattern, label: "Pattern", as: :string, hint: "* matches zero or more, ? matches exactly one character. See more #{link_to('here', 'https://apidock.com/ruby/v2_5_5/File/fnmatch/class')}.".html_safe %>
<%= f.input :note, label: "Note", as: :string %>
<%= f.input :allowed, label: "Upload Allowed", as: :boolean %>
<%= f.input :reason, label: "Ban Reason", as: :string %>