dfinke / InstallModuleFromGitHub

Install PowerShell Modules from GitHub
Apache License 2.0
87 stars 31 forks source link

Branch names with '/' in them cause errors due to unescaped use as file path #21

Open NetzwergX opened 3 years ago

NetzwergX commented 3 years ago
PS> Install-ModuleFromGitHub -GitHubRepo NetzwergX/Windows-Screenfetch -Branch 'fix/Get-Uptime' -Debug                  
Invoke-RestMethod: <redacted>\PowerShell\Modules\InstallModuleFromGitHub\0.3\InstallModuleFromGitHub.psm1:28                                                                                                                   Line |                                                                                                                    28 |                  Invoke-RestMethod $url -OutFile $OutFile                                                             |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                             | Could not find a part of the path '<redacted>\win-screenfetch\fix\Get-Uptime.zip'.                                                                                                                                                       Unblock-File: <redacted>\PowerShell\Modules\InstallModuleFromGitHub\0.3\InstallModuleFromGitHub.psm1:29
Line |
  29 |                  Unblock-File $OutFile
     |                  ~~~~~~~~~~~~~~~~~~~~~
     | Cannot find path '<redacted>\win-screenfetch\fix\Get-Uptime.zip' because it does not exist.

Expand-Archive: <redacted>\PowerShell\Modules\InstallModuleFromGitHub\0.3\InstallModuleFromGitHub.psm1:30
Line |
  30 |  …             Expand-Archive -Path $OutFile -DestinationPath $pwd -Forc …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | The path '<redacted>\win-screenfetch\fix/Get-Uptime.zip' either does not exist or is not a valid file
     | system path.

Get-ChildItem: <redacted>\PowerShell\Modules\InstallModuleFromGitHub\0.3\InstallModuleFromGitHub.psm1:36
Line |                                                                                                                    
  36 |                  $psd1=ls $targetModule *.psd1                                                                        
     |                        ~~~~~~~~~~~~~~~~~~~~~~~                                                                       
     | Cannot find path '<redacted>\win-screenfetch\Windows-Screenfetch-fix\Get-Uptime' because it does not                  
     | exist.

Using the branch name for the file doesn't work when the branch contains a slash. Using branches like release/x, feature/x or fix/x is not uncommon and should be supported.