@@ -252,11 +252,12 @@ export class PackageJSONContribution implements IJSONContribution {
252252 }
253253
254254 private isValidNPMName ( name : string ) : boolean {
255- // following rules from https://github.com/npm/validate-npm-package-name
256- if ( ! name || name . length > 214 || name . match ( / ^ [ _ . ] / ) ) {
255+ // following rules from https://github.com/npm/validate-npm-package-name,
256+ // leading slash added as additional security measure
257+ if ( ! name || name . length > 214 || name . match ( / ^ [ - _ . \s ] / ) ) {
257258 return false ;
258259 }
259- const match = name . match ( / ^ (?: @ ( [ ^ / ] + ?) [ / ] ) ? ( [ ^ / ] + ?) $ / ) ;
260+ const match = name . match ( / ^ (?: @ ( [ ^ / ~ \s ) ( ' ! * ] + ?) [ / ] ) ? ( [ ^ / ~ ) ( ' ! * \s ] + ?) $ / ) ;
260261 if ( match ) {
261262 const scope = match [ 1 ] ;
262263 if ( scope && encodeURIComponent ( scope ) !== scope ) {
@@ -284,7 +285,7 @@ export class PackageJSONContribution implements IJSONContribution {
284285
285286 private npmView ( npmCommandPath : string , pack : string , resource : Uri | undefined ) : Promise < ViewPackageInfo | undefined > {
286287 return new Promise ( ( resolve , _reject ) => {
287- const args = [ 'view' , '--json' , pack , 'description' , 'dist-tags.latest' , 'homepage' , 'version' , 'time' ] ;
288+ const args = [ 'view' , '--json' , '--' , pack , 'description' , 'dist-tags.latest' , 'homepage' , 'version' , 'time' ] ;
288289 const cwd = resource && resource . scheme === 'file' ? dirname ( resource . fsPath ) : undefined ;
289290 cp . execFile ( npmCommandPath , args , { cwd } , ( error , stdout ) => {
290291 if ( ! error ) {
0 commit comments