@@ -252,11 +252,12 @@ export class PackageJSONContribution implements IJSONContribution {
252
252
}
253
253
254
254
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 ] / ) ) {
257
258
return false ;
258
259
}
259
- const match = name . match ( / ^ (?: @ ( [ ^ / ] + ?) [ / ] ) ? ( [ ^ / ] + ?) $ / ) ;
260
+ const match = name . match ( / ^ (?: @ ( [ ^ / ~ \s ) ( ' ! * ] + ?) [ / ] ) ? ( [ ^ / ~ ) ( ' ! * \s ] + ?) $ / ) ;
260
261
if ( match ) {
261
262
const scope = match [ 1 ] ;
262
263
if ( scope && encodeURIComponent ( scope ) !== scope ) {
@@ -284,7 +285,7 @@ export class PackageJSONContribution implements IJSONContribution {
284
285
285
286
private npmView ( npmCommandPath : string , pack : string , resource : Uri | undefined ) : Promise < ViewPackageInfo | undefined > {
286
287
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' ] ;
288
289
const cwd = resource && resource . scheme === 'file' ? dirname ( resource . fsPath ) : undefined ;
289
290
cp . execFile ( npmCommandPath , args , { cwd } , ( error , stdout ) => {
290
291
if ( ! error ) {
0 commit comments