Skip to content

Commit

Permalink
🐛 Allowed .ico files to be uploaded for icons. (#10820)
Browse files Browse the repository at this point in the history
closes #10641

There is already an "icons" section in this json file, but it appears
that that is only used for v0.1 in which there was a "/uploads/icon"
route that passed in a "type" of "icons" to the validation middleware.
However, in v2, there is only a generic "/images/upload" route that is
used for both icons and images, which passes a "type" of "images"
so the .ico information needs to be added to the "images" section
of the json file.
  • Loading branch information
jeffslofish authored and allouis committed Jul 1, 2019
1 parent 15a3dac commit 6ca34a2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/server/config/overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"contentTypes": ["text/csv", "application/csv", "application/octet-stream"]
},
"images": {
"extensions": [".jpg", ".jpeg", ".gif", ".png", ".svg", ".svgz"],
"contentTypes": ["image/jpeg", "image/png", "image/gif", "image/svg+xml"]
"extensions": [".jpg", ".jpeg", ".gif", ".png", ".svg", ".svgz", ".ico"],
"contentTypes": ["image/jpeg", "image/png", "image/gif", "image/svg+xml", "image/x-icon", "image/vnd.microsoft.icon"]
},
"icons": {
"extensions": [".png", ".ico"],
Expand Down
23 changes: 13 additions & 10 deletions core/test/unit/data/importer/index_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ describe('Importer', function () {
});

it('gets the correct extensions', function () {
ImportManager.getExtensions().should.be.instanceof(Array).and.have.lengthOf(10);
ImportManager.getExtensions().should.be.instanceof(Array).and.have.lengthOf(11);
ImportManager.getExtensions().should.containEql('.json');
ImportManager.getExtensions().should.containEql('.zip');
ImportManager.getExtensions().should.containEql('.jpg');
ImportManager.getExtensions().should.containEql('.md');
});

it('gets the correct types', function () {
ImportManager.getContentTypes().should.be.instanceof(Array).and.have.lengthOf(10);
ImportManager.getContentTypes().should.be.instanceof(Array).and.have.lengthOf(12);
ImportManager.getContentTypes().should.containEql('application/octet-stream');
ImportManager.getContentTypes().should.containEql('application/json');
ImportManager.getContentTypes().should.containEql('application/zip');
Expand All @@ -61,27 +61,27 @@ describe('Importer', function () {

it('globs extensions correctly', function () {
ImportManager.getGlobPattern(ImportManager.getExtensions())
.should.equal('+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.json|.md|.markdown|.zip)');
.should.equal('+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.ico|.json|.md|.markdown|.zip)');
ImportManager.getGlobPattern(ImportManager.getDirectories())
.should.equal('+(images|content)');
ImportManager.getGlobPattern(JSONHandler.extensions)
.should.equal('+(.json)');
ImportManager.getGlobPattern(ImageHandler.extensions)
.should.equal('+(.jpg|.jpeg|.gif|.png|.svg|.svgz)');
.should.equal('+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.ico)');
ImportManager.getExtensionGlob(ImportManager.getExtensions())
.should.equal('*+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.json|.md|.markdown|.zip)');
.should.equal('*+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.ico|.json|.md|.markdown|.zip)');
ImportManager.getDirectoryGlob(ImportManager.getDirectories())
.should.equal('+(images|content)');
ImportManager.getExtensionGlob(ImportManager.getExtensions(), 0)
.should.equal('*+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.json|.md|.markdown|.zip)');
.should.equal('*+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.ico|.json|.md|.markdown|.zip)');
ImportManager.getDirectoryGlob(ImportManager.getDirectories(), 0)
.should.equal('+(images|content)');
ImportManager.getExtensionGlob(ImportManager.getExtensions(), 1)
.should.equal('{*/*,*}+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.json|.md|.markdown|.zip)');
.should.equal('{*/*,*}+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.ico|.json|.md|.markdown|.zip)');
ImportManager.getDirectoryGlob(ImportManager.getDirectories(), 1)
.should.equal('{*/,}+(images|content)');
ImportManager.getExtensionGlob(ImportManager.getExtensions(), 2)
.should.equal('**/*+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.json|.md|.markdown|.zip)');
.should.equal('**/*+(.jpg|.jpeg|.gif|.png|.svg|.svgz|.ico|.json|.md|.markdown|.zip)');
ImportManager.getDirectoryGlob(ImportManager.getDirectories(), 2)
.should.equal('**/+(images|content)');
});
Expand Down Expand Up @@ -342,18 +342,21 @@ describe('Importer', function () {

it('has the correct interface', function () {
ImageHandler.type.should.eql('images');
ImageHandler.extensions.should.be.instanceof(Array).and.have.lengthOf(6);
ImageHandler.extensions.should.be.instanceof(Array).and.have.lengthOf(7);
ImageHandler.extensions.should.containEql('.jpg');
ImageHandler.extensions.should.containEql('.jpeg');
ImageHandler.extensions.should.containEql('.gif');
ImageHandler.extensions.should.containEql('.png');
ImageHandler.extensions.should.containEql('.svg');
ImageHandler.extensions.should.containEql('.svgz');
ImageHandler.contentTypes.should.be.instanceof(Array).and.have.lengthOf(4);
ImageHandler.extensions.should.containEql('.ico');
ImageHandler.contentTypes.should.be.instanceof(Array).and.have.lengthOf(6);
ImageHandler.contentTypes.should.containEql('image/jpeg');
ImageHandler.contentTypes.should.containEql('image/png');
ImageHandler.contentTypes.should.containEql('image/gif');
ImageHandler.contentTypes.should.containEql('image/svg+xml');
ImageHandler.contentTypes.should.containEql('image/x-icon');
ImageHandler.contentTypes.should.containEql('image/vnd.microsoft.icon');
ImageHandler.loadFile.should.be.instanceof(Function);
});

Expand Down

0 comments on commit 6ca34a2

Please sign in to comment.