Skip to content

Commit

Permalink
escape the '&' char in windows links
Browse files Browse the repository at this point in the history
The & character is special in windows, so escape it when passing
strings that contain '&' as arguments to cmd.exe.

This fixes a bug where ctrl-clicking on a link with multiple
parameters would only open the substring of the link up to (and not
including) the first ampersand, e.g.,

http://www.foo.bar/index.html?foo=bar&baz=wat

would direct me to:

http://www.foo.bar/index.html?foo=bar
  • Loading branch information
zangold committed May 8, 2024
1 parent 7077a5f commit 2134fbb
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions alacritty/src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,10 @@ impl<'a, N: Notify + 'a, T: EventListener> input::ActionContext<T> for ActionCon
match &hint.action() {
// Launch an external program.
HintAction::Command(command) => {
// Windows requires an escape character (^) before occurrences of ampersand (&)
#[cfg(windows)]
let text = text.replace("&", "^&");

let mut args = command.args().to_vec();
args.push(text);
self.spawn_daemon(command.program(), &args);
Expand Down

0 comments on commit 2134fbb

Please sign in to comment.