prevent svg icons

This commit is contained in:
Joao Moreno 2017-06-23 10:56:45 +02:00
parent 7cee28578b
commit e0dff61012
2 changed files with 20 additions and 0 deletions

View file

@ -502,6 +502,10 @@ export function validateManifest(manifest: Manifest): Manifest {
validateEngineCompatibility(manifest.engines['vscode']);
if (/\.svg$/i.test(manifest.icon || '')) {
throw new Error(`SVGs can't be used as icons: ${manifest.icon}`);
}
return manifest;
}

View file

@ -90,6 +90,17 @@ function assertMissingProperty(manifest: XMLManifest, name: string): void {
assert.equal(property.length, 0, `Property '${name}' should not exist`);
}
function createManifest(extra: Partial<Manifest>): Manifest {
return {
name: 'test',
publisher: 'mocha',
version: '0.0.1',
description: 'test extension',
engines: { vscode: '*' },
...extra
};
}
describe('collect', () => {
it('should catch all files', () => {
@ -192,6 +203,11 @@ describe('validateManifest', () => {
assert.throws(() => { validateManifest({ publisher: 'demo', name: 'demo', version: '1.0.0', engines: null }); });
assert.throws(() => { validateManifest({ publisher: 'demo', name: 'demo', version: '1.0.0', engines: { vscode: null } }); });
});
it('should prevent SVG icons', () => {
assert(validateManifest(createManifest({ icon: 'icon.png' })));
assert.throws(() => { validateManifest(createManifest({ icon: 'icon.svg' })); });
});
});
describe('toVsixManifest', () => {