Skip to content

Commit

Permalink
fix(Core): Hyper and iTerm special symbols path bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Ji4n1ng committed Apr 19, 2019
1 parent 3fa4b00 commit b0fdc67
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion OpenInTerminal-Lite/OpenInTerminal-Lite/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.2.0</string>
<string>0.3.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
Expand Down
4 changes: 2 additions & 2 deletions OpenInTerminal.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@
4725253722680F13003C50DF /* Terminals */ = {
isa = PBXGroup;
children = (
4725253922680F4B003C50DF /* HyperApp.swift */,
4725253A22680F4B003C50DF /* iTermApp.swift */,
4725253822680F4B003C50DF /* TerminalApp.swift */,
4725253A22680F4B003C50DF /* iTermApp.swift */,
4725253922680F4B003C50DF /* HyperApp.swift */,
);
path = Terminals;
sourceTree = "<group>";
Expand Down
17 changes: 15 additions & 2 deletions OpenInTerminalCore/Terminals/HyperApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,21 @@ final class HyperApp : Terminal {

fileprivate extension String {

// FIXME: if path contains "\", application will crash.
// FIXME: if path contains "\" or """, application will crash.
// Special symbols have been tested, except for backslashes and double quotes.
var hyperEscaped: String {
return self.replacingOccurrences(of: " ", with: "\\\\ ").replacingOccurrences(of: "(", with: "\\\\(").replacingOccurrences(of: ")", with: "\\\\)")

var result = ""
let set: [Character] = [" ", "(", ")", "&", "|", ";",
"\"", "'", "<", ">", "`"]

for char in self {
if set.contains(char) {
result += "\\\\"
}
result.append(char)
}

return result
}
}
3 changes: 2 additions & 1 deletion OpenInTerminalCore/Terminals/iTermApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ final class iTermApp : Terminal {

fileprivate extension String {

// FIXME: if path contains "\", application will crash.
// FIXME: if path contains "\" or """, application will crash.
// Special symbols have been tested, except for backslashes and double quotes.
var itermEscaped: String {

var result = ""
Expand Down

0 comments on commit b0fdc67

Please sign in to comment.