@@ -9,6 +9,7 @@ use crate::{
9
9
} ,
10
10
Config , Metrics , Storage ,
11
11
} ;
12
+ use iron:: url:: percent_encoding:: percent_decode;
12
13
use iron:: {
13
14
headers:: { CacheControl , CacheDirective , Expires , HttpDate } ,
14
15
modifiers:: Redirect ,
@@ -44,8 +45,6 @@ impl iron::Handler for RustLangRedirector {
44
45
/// Handler called for `/:crate` and `/:crate/:version` URLs. Automatically redirects to the docs
45
46
/// or crate details page based on whether the given crate version was successfully built.
46
47
pub fn rustdoc_redirector_handler ( req : & mut Request ) -> IronResult < Response > {
47
- use iron:: url:: percent_encoding:: percent_decode;
48
-
49
48
fn redirect_to_doc (
50
49
req : & Request ,
51
50
name : & str ,
@@ -331,14 +330,15 @@ pub fn rustdoc_html_server_handler(req: &mut Request) -> IronResult<Response> {
331
330
path. push_str ( "index.html" ) ;
332
331
req_path. push ( "index.html" ) ;
333
332
}
333
+ let mut path = ctry ! ( req, percent_decode( path. as_bytes( ) ) . decode_utf8( ) ) ;
334
334
335
335
// Attempt to load the file from the database
336
336
let file = match File :: from_path ( & storage, & path, & config) {
337
337
Ok ( file) => file,
338
338
Err ( err) => {
339
339
log:: debug!( "got error serving {}: {}" , path, err) ;
340
340
// If it fails, we try again with /index.html at the end
341
- path. push_str ( "/index.html" ) ;
341
+ path. to_mut ( ) . push_str ( "/index.html" ) ;
342
342
req_path. push ( "index.html" ) ;
343
343
344
344
return if ctry ! ( req, storage. exists( & path) ) {
@@ -1573,6 +1573,21 @@ mod test {
1573
1573
} )
1574
1574
}
1575
1575
1576
+ #[ test]
1577
+ fn test_non_ascii ( ) {
1578
+ wrapper ( |env| {
1579
+ env. fake_release ( )
1580
+ . name ( "const_unit_poc" )
1581
+ . version ( "1.0.0" )
1582
+ . rustdoc_file ( "const_unit_poc/units/constant.Ω.html" )
1583
+ . create ( ) ?;
1584
+ assert_success (
1585
+ "/const_unit_poc/1.0.0/const_unit_poc/units/constant.Ω.html" ,
1586
+ env. frontend ( ) ,
1587
+ )
1588
+ } )
1589
+ }
1590
+
1576
1591
#[ test]
1577
1592
fn test_latest_version_keeps_query ( ) {
1578
1593
wrapper ( |env| {
0 commit comments