Fix AppInstance.GetActivatedEventArgs() for files with Unicode characters#12
Fix AppInstance.GetActivatedEventArgs() for files with Unicode characters#12
Conversation
…ld fail when file path contains unicode characters or special characters (microsoft#5175)" This reverts commit e8d5edf.
Co-authored-by: MuyuanMS <[email protected]>
|
@copilot The behavior remains unchanged - this PR has not fixed the issue yet |
Co-authored-by: MuyuanMS <[email protected]>
I've identified the issue and made additional changes in e7a6ef5. The problem was that Unicode characters in file paths were affecting how the activation type was being detected in the DecodeActivatedEventArgs function, not just how the file path itself was being processed. I've enhanced the DecodeActivatedEventArgs function to:
This should ensure file activations with Unicode characters are correctly identified instead of defaulting to protocol activations. Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
This still has not fixed the issue. |
Co-authored-by: MuyuanMS <[email protected]>
I've implemented a new approach in commit f3e60dd to address the issue with Unicode characters in URIs. Instead of relying on Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
|
I don't want to over-expanding the issue (by replacing all occurrence of |
Co-authored-by: MuyuanMS <[email protected]>
I've implemented a more targeted solution in 4b15146 that addresses both concerns:
The solution is minimal and focused on the specific issue without modifying unrelated code. |
|
You are missing |
Co-authored-by: MuyuanMS <[email protected]>
I've fixed the
This ensures that both the activation type determination and file path extraction work correctly with Unicode characters. |
Summary
This PR fixes an issue where
AppInstance.GetActivatedEventArgs()doesn't correctly handle file activation when the file path contains Unicode characters.Issue
When an application is registered in the shell with a registry event args like:
and a file with Unicode characters (e.g., "新建 文本文档.reg") is opened,
GetActivatedEventArgs()would incorrectly returnExtendedActivationKind.Protocolinstead ofExtendedActivationKind.File, resulting in the file not being retrieved properly.Root cause
The
FileActivatedEventArgs::Deserializemethod wasn't unescaping the file path retrieved from the URI query parameters. When a file path contains Unicode characters, they are URL-encoded in the URI, and the system needs to decode them before using the path.Fix
Added a call to
winrt::Windows::Foundation::Uri::UnescapeComponent()in theFileActivatedEventArgs::Deserializemethod to properly decode the file path with Unicode characters before creating theFileActivatedEventArgsobject.This change ensures that file paths with Unicode characters are properly decoded, allowing the system to correctly identify the activation kind as
ExtendedActivationKind.Fileand properly retrieve the file.Fixes #11.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.