From 16ed672929168fe4714d1a20b3b1906adb0f5345 Mon Sep 17 00:00:00 2001 From: yxshee <84263676+yxshee@users.noreply.github.com> Date: Thu, 19 Nov 2026 17:28:33 +0530 Subject: [PATCH] fix(lexers): preserve literal hashes in SSH config arguments --- lexers/embedded/ssh_config.xml | 87 +++++++------------ .../sshconfig.host-and-comments.actual | 5 ++ .../sshconfig.host-and-comments.expected | 26 ++++++ 3 files changed, 63 insertions(+), 55 deletions(-) diff --git a/lexers/embedded/ssh_config.xml b/lexers/embedded/ssh_config.xml index 1a9a2015d..6903b6d49 100644 --- a/lexers/embedded/ssh_config.xml +++ b/lexers/embedded/ssh_config.xml @@ -26,7 +26,7 @@ - + @@ -37,7 +37,7 @@ - + @@ -48,29 +48,41 @@ - + - + + + + + + + + + + - - - - - - - - + + + - + + + + + + + + + @@ -80,29 +92,13 @@ - + - - - - - - - - - - - - - - - - - - + + @@ -119,29 +115,13 @@ - + - - - - - - - - - - - - - - - - - - + + @@ -149,12 +129,9 @@ - + - - - diff --git a/lexers/testdata/sshconfig.host-and-comments.actual b/lexers/testdata/sshconfig.host-and-comments.actual index e91e1bb6c..176485d4c 100644 --- a/lexers/testdata/sshconfig.host-and-comments.actual +++ b/lexers/testdata/sshconfig.host-and-comments.actual @@ -7,3 +7,8 @@ Host * Host *.example.com !bastion.example.com IdentityFile ~/.ssh/id_ed25519 ProxyJump jump.example.com +Host *#prod # fleet + IdentityFile '/keys/user #1' # primary + IdentityFile /keys/user\ #2 +Match originalhost app#prod + User build#team diff --git a/lexers/testdata/sshconfig.host-and-comments.expected b/lexers/testdata/sshconfig.host-and-comments.expected index 959394d6e..435f46aa0 100644 --- a/lexers/testdata/sshconfig.host-and-comments.expected +++ b/lexers/testdata/sshconfig.host-and-comments.expected @@ -29,5 +29,31 @@ {"type":"NameBuiltin","value":"ProxyJump"}, {"type":"Text","value":" "}, {"type":"LiteralString","value":"jump.example.com"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"Host"}, + {"type":"Text","value":" "}, + {"type":"LiteralStringRegex","value":"*#prod"}, + {"type":"Text","value":" "}, + {"type":"CommentSingle","value":"# fleet"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"IdentityFile"}, + {"type":"Text","value":" "}, + {"type":"LiteralStringSingle","value":"'/keys/user #1'"}, + {"type":"Text","value":" "}, + {"type":"CommentSingle","value":"# primary"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"IdentityFile"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"/keys/user\\ #2"}, + {"type":"Text","value":"\n"}, + {"type":"Keyword","value":"Match"}, + {"type":"Text","value":" "}, + {"type":"Keyword","value":"originalhost"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"app#prod"}, + {"type":"Text","value":"\n "}, + {"type":"NameBuiltin","value":"User"}, + {"type":"Text","value":" "}, + {"type":"LiteralString","value":"build#team"}, {"type":"Text","value":"\n"} ]