File tree Expand file tree Collapse file tree 2 files changed +28
-10
lines changed Expand file tree Collapse file tree 2 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -502,14 +502,14 @@ impl Options {
502
502
if !h. ends_with ( '/' ) {
503
503
h. push ( '/' ) ;
504
504
}
505
- h
505
+ h. replace ( " \\ " , "/" )
506
506
} ) ;
507
507
if let Some ( ref source_code_external_url) = source_code_external_url {
508
- if ! source_code_external_url. starts_with ( "http://" )
509
- && !source_code_external_url . starts_with ( "https://" )
510
- {
511
- diag . struct_err ( "option `--source-code-external-url` argument must be an URL" )
512
- . emit ( ) ;
508
+ if source_code_external_url. starts_with ( "/" ) {
509
+ diag . struct_err (
510
+ "option `--source-code-external-url` argument cannot be an absolute local path" ,
511
+ )
512
+ . emit ( ) ;
513
513
return Err ( 1 ) ;
514
514
}
515
515
}
Original file line number Diff line number Diff line change @@ -1553,6 +1553,21 @@ impl Context {
1553
1553
}
1554
1554
}
1555
1555
1556
+ fn compute_path ( path : String ) -> String {
1557
+ if path. split ( '/' ) . find ( |x| * x == ".." ) . is_none ( ) {
1558
+ return path;
1559
+ }
1560
+ let mut new_path = Vec :: new ( ) ;
1561
+ for part in path. split ( '/' ) {
1562
+ if part == ".." && !new_path. is_empty ( ) {
1563
+ new_path. pop ( ) ;
1564
+ } else {
1565
+ new_path. push ( part) ;
1566
+ }
1567
+ }
1568
+ new_path. join ( "/" )
1569
+ }
1570
+
1556
1571
impl Context {
1557
1572
/// Generates a url appropriate for an `href` attribute back to the source of
1558
1573
/// this item.
@@ -1607,10 +1622,13 @@ impl Context {
1607
1622
} ;
1608
1623
if let Some ( ref source_code_external_url) = self . shared . source_code_external_url {
1609
1624
Some ( format ! (
1610
- "{root}{krate}/{path}#{lines}" ,
1611
- root = source_code_external_url,
1612
- krate = krate,
1613
- path = path,
1625
+ "{path}#{lines}" ,
1626
+ path = compute_path( format!(
1627
+ "{root}{krate}/{path}" ,
1628
+ root = source_code_external_url,
1629
+ krate = krate,
1630
+ path = path,
1631
+ ) , ) ,
1614
1632
lines = lines
1615
1633
) )
1616
1634
} else {
You can’t perform that action at this time.
0 commit comments