-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Accepted Media Types settings validation (#32478)
Co-authored-by: Henrique Guimarães Ribeiro <43561537+rique223@users.noreply.github.com>
- Loading branch information
1 parent
afa560d
commit 97eaa17
Showing
7 changed files
with
79 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@rocket.chat/meteor": patch | ||
--- | ||
|
||
Fixed "File Upload > Accepted Media Types" setting to allow all type of files uploads |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { fileUploadIsValidContentTypeFromSettings } from '../../../../../app/utils/lib/restrictions'; | ||
|
||
describe('fileUploadIsValidContentTypeFromSettings', () => { | ||
it('should return true if type is not defined and whiteList is not defined', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings(undefined, '', '')).to.be.true; | ||
}); | ||
|
||
it('should return false if type is not defined and whiteList is defined', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings(undefined, 'image/jpeg', '')).to.be.false; | ||
}); | ||
|
||
it('should return true if type is defined and whiteList is not defined', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', '', '')).to.be.true; | ||
}); | ||
|
||
it('should return true if type is defined and whiteList is defined and type is in whiteList', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', 'image/jpeg', '')).to.be.true; | ||
}); | ||
|
||
it('should return false if type is defined and whiteList is defined and type is not in whiteList', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/png', 'image/jpeg', '')).to.be.false; | ||
}); | ||
|
||
it('should return false if type is defined and whiteList is not defined and type is in blackList', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', '', 'image/jpeg')).to.be.false; | ||
}); | ||
|
||
it('should return true if type is defined and whiteList is not defined and type is not in blackList', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/png', '', 'image/jpeg')).to.be.true; | ||
}); | ||
|
||
it('should return true if type is defined and whiteList is defined and type is in whiteList with wildcard', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', 'image/*', '')).to.be.true; | ||
}); | ||
|
||
it('should return false if type is defined and whiteList is defined and type is not in whiteList with wildcard', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('text/plain', 'image/*', '')).to.be.false; | ||
}); | ||
|
||
it('should return false if type is defined and whiteList is not defined and type is in blackList with wildcard', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('image/jpeg', '', 'image/*')).to.be.false; | ||
}); | ||
|
||
it('should return true if type is defined and whiteList is defined and type is not in blackList with wildcard', () => { | ||
expect(fileUploadIsValidContentTypeFromSettings('text/plain', '', 'image/*')).to.be.true; | ||
}); | ||
}); |