Skip to content

Add safeUriSchemes setting#20207

Merged
DHowett merged 1 commit into
microsoft:mainfrom
ltrzesniewski:safe-hyperlinks
May 12, 2026
Merged

Add safeUriSchemes setting#20207
DHowett merged 1 commit into
microsoft:mainfrom
ltrzesniewski:safe-hyperlinks

Conversation

@ltrzesniewski
Copy link
Copy Markdown
Contributor

@ltrzesniewski ltrzesniewski commented May 9, 2026

This adds a safeUriSchemes global setting which lets you define
hyperlink URI schemes which the user considers safe. No confirmation
dialog will be shown when trying to open hyperlinks which use these
schemes.

  • This solves the root issue, but doesn't introduce any UI or
    documentation changes. I wanted to validate the approach and
    implementation with you first.
  • I closely followed the code handling the disabledProfileSources
    setting, which is of the same type.
  • This feature does not change the behavior of http, https and
    file schemes.

Validation

I ran the dev terminal, and tested the behavior by clicking on vscode
hyperlinks generated by ripgrep with various safeUriSchemes settings:

  • Setting not defined - asks for confirmation
  • ["vscode"] - does not ask for confirmation
  • ["foo", "vscode"] - does not ask for confirmation
  • ["foo"] - asks for confirmation
  • null - asks for confirmation
  • [] - asks for confirmation
  • [""] - asks for confirmation
  • [{"foo": "bar"}] - fails to deserialize (as expected)

A few uinit tests failed, but they seem unrelated to these changes:

  • KeyBindingTests in UnitTests_SettingsModel, probably because I use
    an AZERTY keyboard.
  • A few Conhost tests, but I didn't touch this part

Refs #20065
Closes #20191

@DHowett
Copy link
Copy Markdown
Member

DHowett commented May 12, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Copy Markdown
Member

@DHowett DHowett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much. This is practically perfect.

I'm literally about to cut the new 1.24 Stable build which has the warning dialog, and I am going to take this in as well.


return true;
}
if (const auto& safeSchemes = _settings.GlobalSettings().SafeUriSchemes())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, so hear me out. should users be allowed to put file in the list to bypass all checks on file URIs?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if so, we can easily throw this ten lines up

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm more than happy either way

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered about the same thing but thought this would be safer and you'd get fewer of those sCaRy hyperlinks reports. 😅

TBH I also thought about adding a * scheme to just allow everything, but wasn't sure if you'd accept it.

Either way, you decide 🙂

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, let's stick with this one for now. If users come asking for more, this is a good framework on which we can build more for them. Thanks so much!

@DHowett DHowett enabled auto-merge (squash) May 12, 2026 16:50
@ltrzesniewski
Copy link
Copy Markdown
Contributor Author

I don't think the failing test is related to the PR.

@DHowett DHowett merged commit fb71a04 into microsoft:main May 12, 2026
16 checks passed
@ltrzesniewski ltrzesniewski deleted the safe-hyperlinks branch May 12, 2026 21:33
DHowett pushed a commit that referenced this pull request May 12, 2026
This adds a `safeUriSchemes` global setting which lets you define
hyperlink URI schemes which the user considers safe. No confirmation
dialog will be shown when trying to open hyperlinks which use these
schemes.

- This solves the root issue, but doesn't introduce any UI or
  documentation changes. I wanted to validate the approach and
  implementation with you first.
- I closely followed the code handling the `disabledProfileSources`
  setting, which is of the same type.
- This feature does not change the behavior of `http`, `https` and
  `file` schemes.

Validation

I ran the dev terminal, and tested the behavior by clicking on `vscode`
hyperlinks generated by ripgrep with various `safeUriSchemes` settings:

- Setting not defined - asks for confirmation
- `["vscode"]` - does not ask for confirmation
- `["foo", "vscode"]` - does not ask for confirmation
- `["foo"]` - asks for confirmation
- `null` - asks for confirmation
- `[]` - asks for confirmation
- `[""]` - asks for confirmation
- `[{"foo": "bar"}]` - fails to deserialize (as expected)

A few uinit tests failed, but they seem unrelated to these changes:
- `KeyBindingTests` in `UnitTests_SettingsModel`, probably because I use
  an AZERTY keyboard.
- A few `Conhost` tests, but I didn't touch this part

Refs #20065
Closes #20191

(cherry picked from commit fb71a04)
Service-Card-Id: PVTI_lADOAF3p4s4BBcTlzgshlaM
Service-Version: 1.24
DHowett pushed a commit that referenced this pull request May 12, 2026
This adds a `safeUriSchemes` global setting which lets you define
hyperlink URI schemes which the user considers safe. No confirmation
dialog will be shown when trying to open hyperlinks which use these
schemes.

- This solves the root issue, but doesn't introduce any UI or
  documentation changes. I wanted to validate the approach and
  implementation with you first.
- I closely followed the code handling the `disabledProfileSources`
  setting, which is of the same type.
- This feature does not change the behavior of `http`, `https` and
  `file` schemes.

Validation

I ran the dev terminal, and tested the behavior by clicking on `vscode`
hyperlinks generated by ripgrep with various `safeUriSchemes` settings:

- Setting not defined - asks for confirmation
- `["vscode"]` - does not ask for confirmation
- `["foo", "vscode"]` - does not ask for confirmation
- `["foo"]` - asks for confirmation
- `null` - asks for confirmation
- `[]` - asks for confirmation
- `[""]` - asks for confirmation
- `[{"foo": "bar"}]` - fails to deserialize (as expected)

A few uinit tests failed, but they seem unrelated to these changes:
- `KeyBindingTests` in `UnitTests_SettingsModel`, probably because I use
  an AZERTY keyboard.
- A few `Conhost` tests, but I didn't touch this part

Refs #20065
Closes #20191

(cherry picked from commit fb71a04)
Service-Card-Id: PVTI_lADOAF3p4s4BQX0-zgshlaI
Service-Version: 1.25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make URL safety configurable

3 participants