Fix ArgumentException crash when InfoPanel encounters paths with illegal characters#1736
Fix ArgumentException crash when InfoPanel encounters paths with illegal characters#1736
Conversation
|
@emako 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
…ming Co-authored-by: emako <[email protected]>
|
Path.GetFileName() - now handles ArgumentException and PathTooLongException Why |
These .NET methods throw
The original crash from issue #1734 showed this exact stack trace: These exceptions occur because Windows file system APIs strictly validate path characters before performing operations. When QuickLook receives paths with problematic characters (e.g., from shell extensions or other sources), these methods fail immediately rather than gracefully handling the invalid input. The defensive programming approach prevents crashes by catching these exceptions and providing fallback behavior instead of letting them bubble up unhandled. |
|
Unimportant exceptions, keep throwing errors |
This PR fixes a crash in QuickLook's InfoPanel when it encounters file paths containing illegal characters. The error manifested as:
Root Cause:
The
InfoPanel.DisplayInfo()method was calling file system operations (File.GetLastWriteTime(),Path.GetFileName(), etc.) without defensive error handling. When QuickLook receives paths containing Windows-illegal characters like<>"|?*:or other invalid path constructs, these operations throw unhandledArgumentException, causing the application to crash.Solution:
Added comprehensive exception handling around all file system operations in
InfoPanel.DisplayInfo():ArgumentExceptionandPathTooLongExceptionArgumentException,UnauthorizedAccessException, andPathTooLongExceptionThe fix provides graceful fallback behavior:
Impact:
This ensures QuickLook remains stable and usable even when dealing with edge cases involving unusual file paths.
Fixes #1734.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.