[PR #2050] [MERGED] Allow empty strings, %Environment-Variable% references in profile "icon" settings - fixes #1468, #1867 #24789

Open
opened 2026-01-31 09:05:20 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2050
Author: @metathinker
Created: 7/20/2019
Status: Merged
Merged: 7/25/2019
Merged by: @DHowett-MSFT

Base: masterHead: icon-paths-1468-1867


📝 Commits (6)

  • 1eb2811 Allow empty strings, %Environment-Variable% references in profile "icon" settings - fixes bugs 1468, 1867
  • c8e8063 Merge branch 'master' (69c67f8a8e) into icon-paths-1468-1867 (1eb2811cab)
  • 5e85bab respond to CR feedback
  • 3fdec0d why does the build keep changing this file?
  • 6ae172b Apply suggestions from code review (commit from github.com)
  • ee8fc6c fix build error due to last change

📊 Changes

6 files changed (+7 additions, -144 deletions)

View changed files

📝 src/cascadia/TerminalApp/App.cpp (+3 -2)
📝 src/cascadia/TerminalApp/CascadiaSettings.cpp (+2 -22)
📝 src/cascadia/TerminalApp/CascadiaSettings.h (+0 -1)
📝 src/cascadia/TerminalApp/Profile.cpp (+1 -1)
📝 src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest (+0 -118)
📝 src/inc/LibraryIncludes.h (+1 -0)

📄 Description

Summary of the pull request

Previously, trying to set the "icon" property of a settings profile to either the empty string or a string containing %environment variable names% would cause Terminal to crash when loading that profile into the profile selection menu. Now, empty strings for "icon" are treated the same as JSON null or not setting the property at all, and environment variable references in the "icon" value are expanded.

Detailed description of the pull request / Additional comments

To expand environment variables, I first tried reusing the existing ExpandEnvironmentVariableStrings() helper in TerminalApp/CascadiaSettings.cpp, but then I remembered that the Windows Implementation Libraries already provide their own wrapper for ExpandEnvironmentStrings(), so instead I deleted ExpandEnvironmentVariableStrings() and replaced its existing usages with wil::ExpandEnvironmentStringsW(). I then used wil::ExpandEnvironmentStringsW() when resolving the icon path as well.

Validation steps performed

Manual testing by taking a default profiles.json file and changing the '"icon" value for one profile, with empty string and with strings containing %ProgramFiles% at the start.

PR Checklist

  • Closes #1468, Closes TerminalControl handles ALT+NUMPAD input poorly (#1867)
  • CLA signed - N/A; I work for Microsoft
  • Tests added/passed
    I wasn't sure where to add these. It seems like the best place would be in ut_app/SettingsTests.cpp but that file has a comment that due to TerminalSettings and other WinRT types, it doesn't work right in Azure DevOps CI?
  • Requires documentation to be updated - N/A, no requirements changes
  • I've discussed this with core contributors already

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2050 **Author:** [@metathinker](https://github.com/metathinker) **Created:** 7/20/2019 **Status:** ✅ Merged **Merged:** 7/25/2019 **Merged by:** [@DHowett-MSFT](https://github.com/DHowett-MSFT) **Base:** `master` ← **Head:** `icon-paths-1468-1867` --- ### 📝 Commits (6) - [`1eb2811`](https://github.com/microsoft/terminal/commit/1eb2811cab24a6b805ad105653b56d61c67c41c0) Allow empty strings, %Environment-Variable% references in profile "icon" settings - fixes bugs 1468, 1867 - [`c8e8063`](https://github.com/microsoft/terminal/commit/c8e8063336d851f5af0b15c96b309b83d5873c79) Merge branch 'master' (69c67f8a8eb32c1eb43b8b912c117f522f003c85) into icon-paths-1468-1867 (1eb2811cab24a6b805ad105653b56d61c67c41c0) - [`5e85bab`](https://github.com/microsoft/terminal/commit/5e85babd8cf3a77d9cfd46463842a44646901672) respond to CR feedback - [`3fdec0d`](https://github.com/microsoft/terminal/commit/3fdec0d249334228b3a47f7b13d33abcd591ce25) why does the build keep changing this file? - [`6ae172b`](https://github.com/microsoft/terminal/commit/6ae172b13f667fcf565a73d71d5f20c8b66cb61d) Apply suggestions from code review (commit from github.com) - [`ee8fc6c`](https://github.com/microsoft/terminal/commit/ee8fc6c1e97cc8da836fea5ba8ccfc0af3e433a5) fix build error due to last change ### 📊 Changes **6 files changed** (+7 additions, -144 deletions) <details> <summary>View changed files</summary> 📝 `src/cascadia/TerminalApp/App.cpp` (+3 -2) 📝 `src/cascadia/TerminalApp/CascadiaSettings.cpp` (+2 -22) 📝 `src/cascadia/TerminalApp/CascadiaSettings.h` (+0 -1) 📝 `src/cascadia/TerminalApp/Profile.cpp` (+1 -1) 📝 `src/cascadia/ut_app/TerminalApp.Unit.Tests.manifest` (+0 -118) 📝 `src/inc/LibraryIncludes.h` (+1 -0) </details> ### 📄 Description ### Summary of the pull request Previously, trying to set the `"icon"` property of a settings profile to either the empty string or a string containing `%environment variable names%` would cause Terminal to crash when loading that profile into the profile selection menu. Now, empty strings for `"icon"` are treated the same as JSON `null` or not setting the property at all, and environment variable references in the `"icon"` value are expanded. ### Detailed description of the pull request / Additional comments To expand environment variables, I first tried reusing the existing ExpandEnvironmentVariableStrings() helper in TerminalApp/CascadiaSettings.cpp, but then I remembered that the [Windows Implementation Libraries](https://github.com/microsoft/wil) already provide their own wrapper for ExpandEnvironmentStrings(), so instead I deleted ExpandEnvironmentVariableStrings() and replaced its existing usages with [wil::ExpandEnvironmentStringsW()](https://github.com/microsoft/wil/blob/7a6f0679be9cd625f54a21bb0ce06c39958b13a5/include/wil/win32_helpers.h#L338-L347). I then used wil::ExpandEnvironmentStringsW() when resolving the icon path as well. ### Validation steps performed Manual testing by taking a default `profiles.json` file and changing the `'"icon"` value for one profile, with empty string and with strings containing `%ProgramFiles%` at the start. ### PR Checklist * [x] Closes #1468, Closes #1867 * [x] CLA signed - N/A; I work for Microsoft * [ ] Tests added/passed I wasn't sure where to add these. It seems like the best place would be in ut_app/SettingsTests.cpp but that file has a comment that due to TerminalSettings and other WinRT types, it doesn't work right in Azure DevOps CI? * [x] Requires documentation to be updated - N/A, no requirements changes * [ ] I've discussed this with core contributors already --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:05:20 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#24789