Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
337
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
25
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
aa55aced
Unverified
Commit
aa55aced
authored
4 years ago
by
coord_e
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix not to reject non-image file uploads (#6664)
* fix not to reject non-image file uploads * handle an error from sharp
parent
eb70d6f2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/services/drive/add-file.ts
+23
-5
23 additions, 5 deletions
src/services/drive/add-file.ts
with
23 additions
and
5 deletions
src/services/drive/add-file.ts
+
23
−
5
View file @
aa55aced
...
...
@@ -160,12 +160,30 @@ export async function generateAlts(path: string, type: string, generateWeb: bool
}
}
const
img
=
sharp
(
path
);
const
metadata
=
await
img
.
metadata
();
const
isAnimated
=
metadata
.
pages
&&
metadata
.
pages
>
1
;
if
(
!
[
'
image/jpeg
'
,
'
image/png
'
,
'
image/webp
'
].
includes
(
type
))
{
logger
.
debug
(
`web image and thumbnail not created (not an required file)`
);
return
{
webpublic
:
null
,
thumbnail
:
null
};
}
let
img
:
sharp
.
Sharp
|
null
=
null
;
try
{
img
=
sharp
(
path
);
const
metadata
=
await
img
.
metadata
();
const
isAnimated
=
metadata
.
pages
&&
metadata
.
pages
>
1
;
// skip animated
if
(
isAnimated
)
{
// skip animated
if
(
isAnimated
)
{
return
{
webpublic
:
null
,
thumbnail
:
null
};
}
}
catch
(
e
)
{
logger
.
warn
(
`sharp failed:
${
e
}
`
);
return
{
webpublic
:
null
,
thumbnail
:
null
...
...
This diff is collapsed.
Click to expand it.
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