File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ impl SourceId {
131
131
pub fn from_url ( string : & str ) -> CargoResult < SourceId > {
132
132
let mut parts = string. splitn ( 2 , '+' ) ;
133
133
let kind = parts. next ( ) . unwrap ( ) ;
134
- let url = parts. next ( ) . unwrap ( ) ;
134
+ let url = try! ( parts. next ( ) . ok_or ( human ( format ! ( "invalid source `{}`" , string ) ) ) ) ;
135
135
136
136
match kind {
137
137
"git" => {
Original file line number Diff line number Diff line change @@ -280,6 +280,45 @@ Caused by:
280
280
" ) ) ;
281
281
}
282
282
283
+ #[ test]
284
+ fn bad_source_in_cargo_lock ( ) {
285
+ Package :: new ( "foo" , "0.1.0" ) . publish ( ) ;
286
+
287
+ let p = project ( "bar" )
288
+ . file ( "Cargo.toml" , r#"
289
+ [project]
290
+ name = "bar"
291
+ version = "0.0.1"
292
+ authors = []
293
+
294
+ [dependencies]
295
+ foo = "0.1.0"
296
+ "# )
297
+ . file ( "src/lib.rs" , "" )
298
+ . file ( "Cargo.lock" , r#"
299
+ [root]
300
+ name = "bar"
301
+ version = "0.0.1"
302
+ dependencies = [
303
+ "foo 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
304
+ ]
305
+
306
+ [[package]]
307
+ name = "foo"
308
+ version = "0.1.0"
309
+ source = "You shall not parse"
310
+ "# ) ;
311
+ p. build ( ) ;
312
+
313
+ assert_that ( p. cargo ( "build" ) . arg ( "--verbose" ) ,
314
+ execs ( ) . with_status ( 101 ) . with_stderr ( "\
315
+ [ERROR] failed to parse lock file at: [..]
316
+
317
+ Caused by:
318
+ invalid source `You shall not parse` for the key `package.source`
319
+ " ) ) ;
320
+ }
321
+
283
322
#[ test]
284
323
fn bad_git_dependency ( ) {
285
324
let foo = project ( "foo" )
You can’t perform that action at this time.
0 commit comments