@@ -157,11 +157,11 @@ impl Installer {
157157 let libs_dir = mojang. base ( ) . libraries_dir ( ) ;
158158
159159 // Start by checking patched client and universal client.
160- if ! check_exists ( & config. name . with_classifier ( Some ( "client" ) ) . file ( libs_dir) ) {
160+ if let Some ( client_gav ) = config. name . with_classifier ( Some ( "client" ) ) && ! check_exists ( & client_gav . file ( libs_dir) ) {
161161 break InstallReason :: MissingPatchedClient ;
162162 }
163163
164- if ! check_exists ( & config. name . with_classifier ( Some ( "universal" ) ) . file ( libs_dir) ) {
164+ if let Some ( universal_gav ) = config. name . with_classifier ( Some ( "universal" ) ) && ! check_exists ( & universal_gav . file ( libs_dir) ) {
165165 break InstallReason :: MissingUniversalClient ;
166166 }
167167
@@ -704,7 +704,7 @@ impl InstallConfig {
704704
705705 Some ( Self {
706706 default_prefix : "forge" ,
707- name : Gav :: new ( "net.minecraftforge" , "forge" , name, None , None ) ,
707+ name : Gav :: new ( "net.minecraftforge" , "forge" , name, None , None ) ? ,
708708 repo_url : "https://maven.minecraftforge.net" ,
709709 game_version : if game_version == "1.7.10_pre4" {
710710 "1.7.10-pre4" . to_string ( ) // The only pre-release supported.
@@ -746,10 +746,10 @@ impl InstallConfig {
746746 let game_version;
747747
748748 if name == "47.1.82" || name. starts_with ( "1.20.1-" ) {
749- gav = Gav :: new ( "net.neoforged" , "forge" , name, None , None ) ;
749+ gav = Gav :: new ( "net.neoforged" , "forge" , name, None , None ) ? ;
750750 game_version = "1.20.1" . to_string ( ) ;
751751 } else {
752- gav = Gav :: new ( "net.neoforged" , "neoforge" , name, None , None ) ;
752+ gav = Gav :: new ( "net.neoforged" , "neoforge" , name, None , None ) ? ;
753753 game_version = match parse_generic_version :: < 2 , 2 > ( name) ? {
754754 [ major, 0 ] => format ! ( "1.{major}" ) ,
755755 [ major, minor] => format ! ( "1.{major}.{minor}" ) ,
@@ -788,7 +788,13 @@ fn try_install(
788788 // simply no installer for this version!
789789 handler. on_event ( Event :: FetchInstaller { version : config. name . version ( ) } ) ;
790790
791- let installer_gav = config. name . with_classifier ( Some ( "installer" ) ) ;
791+ // Handle the case where the next installer gav could not be constructed, too long?
792+ let Some ( installer_gav) = config. name . with_classifier ( Some ( "installer" ) ) else {
793+ return Err ( Error :: InstallerNotFound {
794+ version : config. name . version ( ) . to_string ( ) ,
795+ } ) ;
796+ } ;
797+
792798 let installer_url = format ! ( "{}/{}" , config. repo_url, installer_gav. url( ) ) ;
793799
794800 // Download and check result in case installer is just not found.
@@ -904,8 +910,7 @@ fn try_install(
904910 let lib_dl = & lib. downloads . artifact ;
905911
906912 let lib_file = if let Some ( lib_path) = & lib_dl. path {
907- // FIXME: Insecure joining!
908- libraries_dir. join ( lib_path)
913+ libraries_dir. join ( base:: check_path_relative_and_safe ( lib_path) ?)
909914 } else {
910915 lib. name . file ( & libraries_dir)
911916 } ;
@@ -949,9 +954,8 @@ fn try_install(
949954 }
950955 _ => {
951956 // This is a file that we should extract to the temp directory.
952- // FIXME: Insecure joining.
953957 let entry = entry. strip_prefix ( '/' ) . unwrap_or ( entry) ;
954- let tmp_file = tmp_dir. join ( entry) ;
958+ let tmp_file = tmp_dir. join ( base :: check_path_relative_and_safe ( entry) ? ) ;
955959 extract_installer_file ( installer_file, & mut installer_zip, entry, & tmp_file) ?;
956960 InstallDataTypedEntry :: File ( tmp_file)
957961 }
0 commit comments