Skip to content

Commit

Permalink
fixed #358 - quotes in connection instructions on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Aug 7, 2023
1 parent fc1a93b commit b5ec092
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 29 deletions.
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions warpgate-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@sveltejs/vite-plugin-svelte": "^1.4.0",
"@tsconfig/svelte": "^3.0.0",
"@types/qrcode": "^1.5.0",
"@types/shell-escape": "^0.2.1",
"@types/ua-parser-js": "^0.7.36",
"@typescript-eslint/eslint-plugin": "^5.43.0",
"@typescript-eslint/parser": "^5.58.0",
"bootstrap": "^5.2.0-beta1",
Expand All @@ -46,7 +46,6 @@
"otplib": "^12.0.1",
"qrcode": "^1.5.1",
"sass": "^1.61.0",
"shell-escape": "^0.2.0",
"svelte": "^3.58.0",
"svelte-check": "^2.9.2",
"svelte-fa": "^3.0.1",
Expand All @@ -58,6 +57,7 @@
"thenby": "^1.3.4",
"tslib": "^2.5.0",
"typescript": "^4.9.4",
"ua-parser-js": "^1.0.35",
"vite": "^3.2.4",
"vite-plugin-checker": "^0.5.3",
"vite-tsconfig-paths": "^4.0.9",
Expand Down
2 changes: 1 addition & 1 deletion warpgate-web/src/common/protocols.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import shellEscape from 'shell-escape'
import { shellEscape } from 'gateway/lib/shellEscape'
import type { Info } from 'gateway/lib/api'

export interface ConnectionOptions {
Expand Down
32 changes: 32 additions & 0 deletions warpgate-web/src/gateway/lib/shellEscape.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { UAParser } from 'ua-parser-js'

function escapeUnix (arg: string): string {
if (!/^[A-Za-z0-9_\/-]+$/.test(arg)) {
return ('\'' + arg.replace(/'/g, '\'"\'"\'') + '\'').replace(/''/g, '')
}
return arg
}

function escapeWin (arg: string): string {
if (!/^[A-Za-z0-9_\/-]+$/.test(arg)) {
return '"' + arg.replace(/"/g, '""') + '"'
}
return arg
}

const isWin = new UAParser().getOS().name === 'Windows'

export function shellEscape (stringOrArray: string[]|string): string {
const ret = []

const escapePath = isWin ? escapeWin : escapeUnix

if (typeof stringOrArray == 'string') {
return escapePath(stringOrArray)
} else {
stringOrArray.forEach(function (member) {
ret.push(escapePath(member))
})
return ret.join(' ')
}
}
23 changes: 9 additions & 14 deletions warpgate-web/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -340,10 +340,10 @@
resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.3.13.tgz#da4bfd73f49bd541d28920ab0e2bf0ee80f71c91"
integrity sha512-21cFJr9z3g5dW8B0CVI9g2O9beqaThGQ6ZFBqHfwhzLDKUxaqTIy3vnfah/UPkfOiF2pLq+tGz+W8RyCskuslw==

"@types/shell-escape@^0.2.1":
version "0.2.1"
resolved "https://registry.yarnpkg.com/@types/shell-escape/-/shell-escape-0.2.1.tgz#34631545340aa61bbabb672b906f1b910cd42757"
integrity sha512-95hZXmBvwtvsLMPefKT9xquUSAJXsVDUaipyUiYoYi3ZdLhZ3w30w230Ugs96IdoJQb5ECvj0D82Jj/op00qWQ==
"@types/ua-parser-js@^0.7.36":
version "0.7.36"
resolved "https://registry.yarnpkg.com/@types/ua-parser-js/-/ua-parser-js-0.7.36.tgz#9bd0b47f26b5a3151be21ba4ce9f5fa457c5f190"
integrity sha512-N1rW+njavs70y2cApeIw1vLMYXRwfBy+7trgavGuuTfOd7j1Yh7QTRc/yqsPl6ncokt72ZXuxEU0PiCp9bSwNQ==

"@typescript-eslint/eslint-plugin@^5.43.0":
version "5.43.0"
Expand Down Expand Up @@ -2442,11 +2442,6 @@ shebang-regex@^3.0.0:
resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172"
integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==

shell-escape@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/shell-escape/-/shell-escape-0.2.0.tgz#68fd025eb0490b4f567a027f0bf22480b5f84133"
integrity sha512-uRRBT2MfEOyxuECseCZd28jC1AJ8hmqqneWQ4VWUTgCAFvb3wKU1jLqj6egC4Exrr88ogg3dp+zroH4wJuaXzw==

side-channel@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
Expand Down Expand Up @@ -2753,11 +2748,6 @@ tslib@^2.1.0, tslib@^2.4.0, tslib@^2.5.0:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==

tslib@^2.5.0:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==

tsutils@^3.21.0:
version "3.21.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-3.21.0.tgz#b48717d394cea6c1e096983eed58e9d61715b623"
Expand Down Expand Up @@ -2787,6 +2777,11 @@ typescript@*, typescript@^4.9.4:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78"
integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==

ua-parser-js@^1.0.35:
version "1.0.35"
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-1.0.35.tgz#c4ef44343bc3db0a3cbefdf21822f1b1fc1ab011"
integrity sha512-fKnGuqmTBnIE+/KXSzCn4db8RTigUzw1AN0DmdU6hJovUTbYJKyqj+8Mt1c4VfRDnOVJnENmfYkIPZ946UrSAA==

unbox-primitive@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.1.tgz#085e215625ec3162574dc8859abee78a59b14471"
Expand Down

0 comments on commit b5ec092

Please sign in to comment.