Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
RDMS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
researchdata
RDMS
Commits
d020b5b6
Commit
d020b5b6
authored
1 year ago
by
Kapil Patel
Committed by
Anusha Ranganathan
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Add validation for uploded file
parent
bbee3ce4
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!225
Add validation for uploded file
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
hyrax/app/models/hyrax/uploaded_file.rb
+10
-0
10 additions, 0 deletions
hyrax/app/models/hyrax/uploaded_file.rb
hyrax/config/restricted_files.yml
+5
-0
5 additions, 0 deletions
hyrax/config/restricted_files.yml
with
15 additions
and
0 deletions
hyrax/app/models/hyrax/uploaded_file.rb
+
10
−
0
View file @
d020b5b6
...
...
@@ -15,6 +15,7 @@ module Hyrax
belongs_to
:user
,
class_name:
'::User'
before_create
:set_characterization_data
validate
:uploaded_file_name
##
# Associate a {FileSet} with this uploaded file.
#
...
...
@@ -44,5 +45,14 @@ module Hyrax
self
.
characterization_data
[
:file_size
]
=
file
.
size
self
.
characterization_data
[
:original_checksum
]
=
Digest
::
SHA1
.
file
(
file
.
path
).
to_s
end
def
uploaded_file_name
parsed_file
=
YAML
.
load_file
(
Rails
.
root
.
join
(
'config'
,
'restricted_files.yml'
))
file_name
=
file
.
file
.
original_filename
if
parsed_file
[
'restricted_file_names'
].
include?
(
file_name
.
gsub
(
/[\s_\-]/
,
''
).
downcase
)
||
file_name
.
start_with?
(
'.'
)
errors
.
add
(
:base
,
"This file name is restricted."
)
end
end
end
end
\ No newline at end of file
This diff is collapsed.
Click to expand it.
hyrax/config/restricted_files.yml
0 → 100644
+
5
−
0
View file @
d020b5b6
restricted_file_names
:
-
metadata.json
-
meta.json
-
.DS_Store
-
desktop.ini
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Pascal Ernster
@ernstprr
mentioned in issue
#39
·
1 year ago
mentioned in issue
#39
mentioned in issue #39
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment