winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Failed in renaming the installer if the InstallerUrl contains invalid filename characters

Open SpecterShell opened this issue 3 years ago • 0 comments

Brief description of your issue

After downloading the installer, WinGet will rename it according to the URL. However, if the URL contains invalid characters such as *, the renaming will fail.

EDIT: A workaround is to perform URLEncode on these characters.

Examples: https://github.com/microsoft/winget-pkgs/pull/87776

Steps to reproduce

  1. Use one of the following URLs as InstallerUrl in the manifest:
    • https://mdn.alipayobjects.com/ind_developertool/afts/file/A*zd7ET7KDuogAAAAAAAAAAAAADlx-AQ?af_fileName=AlipayKeyTool-2.0.1.exe
    • https://mdn.alipayobjects.com/ind_developertool/afts/file/A*ug2UTJtlbKEAAAAAAAAAAAAADlx-AQ?af_fileName=AlipayKeyTool-2.0.2.exe
  2. Use winget install -m .\path\to\the\manifest to install
  3. Installation fails

Expected behavior

Rename the file according to the response header Content-Disposition instead of the URL.

Actual behavior

Renaming failed and installation stopped. The following log comes from the validation pipeline. It is the same on my device.

2022-11-08 04:20:46.488 [CORE] WinGet, version [1.3.2091], activity [{847589FC-8A14-405D-A00F-9814D8D240EB}]
2022-11-08 04:20:46.489 [CORE] OS: Windows.Desktop v10.0.19044.1889
2022-11-08 04:20:46.489 [CORE] Command line Args: C:\Users\validator\AppData\Local\Microsoft\WindowsApps\winget.exe install --manifest D:\TRANSFER\9602fc98-5f5f-ed11-9566-0022484bf065\Manifest.yaml --scope user --accept-package-agreements
2022-11-08 04:20:46.489 [CORE] Package: Microsoft.DesktopAppInstaller v1.18.2091.0
2022-11-08 04:20:46.489 [CORE] IsCOMCall:0; Caller: winget-cli
2022-11-08 04:20:46.503 [CLI ] WinGet invoked with arguments: 'install' '--manifest' 'D:\TRANSFER\9602fc98-5f5f-ed11-9566-0022484bf065\Manifest.yaml' '--scope' 'user' '--accept-package-agreements'
2022-11-08 04:20:46.503 [CLI ] Found subcommand: install
2022-11-08 04:20:46.503 [CLI ] Leaf command to execute: root:install
2022-11-08 04:20:46.518 [CLI ] Executing command: install
2022-11-08 04:20:46.528 [CLI ] Manifest fields: Name [支付宝开放平台密钥工具], Version [2.0.0]
2022-11-08 04:20:46.533 [CLI ] Starting installer selection.
2022-11-08 04:20:46.533 [CLI ] Installer [X64,nullsoft,Machine,] not applicable: Installer scope does not match required scope: Machine != User
2022-11-08 04:20:46.533 [CLI ] Completed installer selection.
2022-11-08 04:20:46.566 [CLI ] Generated temp download path: C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3
2022-11-08 04:20:46.567 [CORE] Downloading to path: C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3
2022-11-08 04:20:46.567 [CORE] DeliveryOptimization downloading from url: https://mdn.alipayobjects.com/ind_developertool/afts/file/A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ?af_fileName=AlipayKeyTool-2.0.0.exe
2022-11-08 04:20:52.642 [CORE] Download completed.
2022-11-08 04:21:02.832 [CORE] Started applying motw to C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3 with zone: 3
2022-11-08 04:21:02.837 [CORE] Finished applying motw
2022-11-08 04:21:02.839 [CLI ] Installer hash verified
2022-11-08 04:21:02.840 [CORE] Started applying motw using IAttachmentExecute to C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3
2022-11-08 04:21:17.643 [CORE] Finished applying motw using IAttachmentExecute. Result: 0 IAttachmentExecute::Save() result: 0
2022-11-08 04:21:17.645 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(80)\WindowsPackageManager.dll!00007FFAB5B0B7B5: (caller: 00007FFAB593FD8C) LogHr(1) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:17.645 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(92)\WindowsPackageManager.dll!00007FFAB5B0B7EC: (caller: 00007FFAB593FD8C) LogHr(2) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:19.477 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(103)\WindowsPackageManager.dll!00007FFAB5B0B823: (caller: 00007FFAB593FD8C) LogHr(3) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:24.872 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(103)\WindowsPackageManager.dll!00007FFAB5B0B823: (caller: 00007FFAB593FD8C) LogHr(4) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:32.221 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(103)\WindowsPackageManager.dll!00007FFAB5B0B823: (caller: 00007FFAB593FD8C) LogHr(5) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:32.336 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(103)\WindowsPackageManager.dll!00007FFAB5B0B823: (caller: 00007FFAB593FD8C) LogHr(6) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:32.445 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(103)\WindowsPackageManager.dll!00007FFAB5B0B823: (caller: 00007FFAB593FD8C) LogHr(7) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: rename: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:32.446 [FAIL] D:\a\_work\1\s\external\pkg\src\AppInstallerCommonCore\Filesystem.cpp(118)\WindowsPackageManager.dll!00007FFAB5B0B85A: (caller: 00007FFAB593FD8C) LogHr(8) tid(1868) 8007023E {Application Error}

The exception %s (0x    Msg:[std::exception: create_hard_link: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"] 

2022-11-08 04:21:34.118 [CLI ] Caught std::exception: copy_file: The filename, directory name, or volume label syntax is incorrect.: "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\a61dac056d575d2d350125616d8db9d7a67e35ad7361ea6750be1ebebae450f3", "C:\Users\VALIDA~1\AppData\Local\Temp\WinGet\Alibaba.AlipayKeyTool.2.0.0\A*Es2PTIHkkdwAAAAAAAAAAAAADlx-AQ.exe"

Environment

Windows 程序包管理器(预览) v1.4.2161-preview
版权所有 (C) Microsoft Corporation。保留所有权利。

Windows: Windows.Desktop v10.0.22621.755
系统体系结构: X64
程序包: Microsoft.DesktopAppInstaller v1.19.2161.0

SpecterShell avatar Nov 08 '22 12:11 SpecterShell