File tree 3 files changed +12
-3
lines changed 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -833,6 +833,9 @@ Run `{cmd}` to see possible targets."
833
833
( None , None ) => config. default_registry ( ) ?. map ( RegistryOrIndex :: Registry ) ,
834
834
( None , Some ( i) ) => Some ( RegistryOrIndex :: Index ( i. into_url ( ) ?) ) ,
835
835
( Some ( r) , None ) => {
836
+ if r. is_empty ( ) {
837
+ bail ! ( "registry name cannot be empty" ) ;
838
+ }
836
839
restricted_names:: validate_package_name ( r, "registry name" , "" ) ?;
837
840
Some ( RegistryOrIndex :: Registry ( r. to_string ( ) ) )
838
841
}
@@ -848,6 +851,9 @@ Run `{cmd}` to see possible targets."
848
851
match self . _value_of ( "registry" ) . map ( |s| s. to_string ( ) ) {
849
852
None => config. default_registry ( ) ,
850
853
Some ( registry) => {
854
+ if registry. is_empty ( ) {
855
+ bail ! ( "registry name cannot be empty" ) ;
856
+ }
851
857
restricted_names:: validate_package_name ( & registry, "registry name" , "" ) ?;
852
858
Ok ( Some ( registry) )
853
859
}
Original file line number Diff line number Diff line change @@ -1551,6 +1551,9 @@ impl Config {
1551
1551
1552
1552
/// Gets the index for a registry.
1553
1553
pub fn get_registry_index ( & self , registry : & str ) -> CargoResult < Url > {
1554
+ if registry. is_empty ( ) {
1555
+ bail ! ( "registry name cannot be empty" ) ;
1556
+ }
1554
1557
validate_package_name ( registry, "registry name" , "" ) ?;
1555
1558
if let Some ( index) = self . get_string ( & format ! ( "registries.{}.index" , registry) ) ? {
1556
1559
self . resolve_registry_index ( & index) . with_context ( || {
Original file line number Diff line number Diff line change @@ -1568,7 +1568,7 @@ fn config_empty_registry_name() {
1568
1568
. with_status ( 101 )
1569
1569
. with_stderr (
1570
1570
"\
1571
- [ERROR] registry index was not found in any configuration: `` ",
1571
+ [ERROR] registry name cannot be empty ",
1572
1572
)
1573
1573
. run ( ) ;
1574
1574
}
@@ -1583,7 +1583,7 @@ fn empty_registry_flag() {
1583
1583
. with_status ( 101 )
1584
1584
. with_stderr (
1585
1585
"\
1586
- [ERROR] registry index was not found in any configuration: `` ",
1586
+ [ERROR] registry name cannot be empty ",
1587
1587
)
1588
1588
. run ( ) ;
1589
1589
}
@@ -1618,7 +1618,7 @@ fn empty_dependency_registry() {
1618
1618
[ERROR] failed to parse manifest at `[CWD]/Cargo.toml`
1619
1619
1620
1620
Caused by:
1621
- registry index was not found in any configuration: `` " ,
1621
+ registry name cannot be empty " ,
1622
1622
)
1623
1623
. run ( ) ;
1624
1624
}
You can’t perform that action at this time.
0 commit comments