diff --git a/src/offline/2globalsUNIX.go b/src/offline/2globalsUNIX.go index 84749fa..40cf8ad 100644 --- a/src/offline/2globalsUNIX.go +++ b/src/offline/2globalsUNIX.go @@ -8,5 +8,7 @@ var ConfigDir = home + "/.config/libmutton" var ConfigPath = ConfigDir + "/libmutton.ini" // PathSeparator defines the character used to separate directories in a path (platform-specific) -const PathSeparator = "/" -const Windows = false // TODO temporary, remove after native sync is implemented +const ( + PathSeparator = "/" + Windows = false // TODO temporary, remove after native sync is implemented +) diff --git a/src/offline/2globalsWIN.go b/src/offline/2globalsWIN.go index 2306b52..8020062 100644 --- a/src/offline/2globalsWIN.go +++ b/src/offline/2globalsWIN.go @@ -8,5 +8,7 @@ var ConfigDir = home + "\\AppData\\Local\\libmutton" var ConfigPath = ConfigDir + "\\libmutton.ini" // PathSeparator defines the character used to separate directories in a path (platform-specific) -const PathSeparator = "\\" -const Windows = true // TODO temporary, remove after native sync is implemented +const ( + PathSeparator = "\\" + Windows = true // TODO temporary, remove after native sync is implemented +) diff --git a/src/offline/copyWIN.go b/src/offline/copyWIN.go index 5f0039d..2a6c72b 100644 --- a/src/offline/copyWIN.go +++ b/src/offline/copyWIN.go @@ -12,7 +12,7 @@ import ( // CopyField copies a field from an entry to the clipboard func copyField(copySubject string, executableName string) { - cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", copySubject)) + cmd := exec.Command("powershell.exe", "-c", fmt.Sprintf("echo '%s' | Set-Clipboard", strings.ReplaceAll(copySubject, "'", "''"))) err := cmd.Run() if err != nil { fmt.Println(AnsiError + "Failed to copy to clipboard: " + err.Error() + AnsiReset) diff --git a/src/offline/utilitiesMisc.go b/src/offline/utilitiesMisc.go index 3808143..d35e9f1 100644 --- a/src/offline/utilitiesMisc.go +++ b/src/offline/utilitiesMisc.go @@ -11,6 +11,8 @@ import ( "strings" ) +const extendedCharset = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" + // TargetIsFile TargetStatusCheck checks if the targetLocation is a file, directory, or is inaccessible // failCondition: 0 = fail on inaccessible, 1 = fail on inaccessible/file, 2 = fail on inaccessible/directory // returns: isFile, isAccessible @@ -93,17 +95,13 @@ func RemoveTrailingEmptyStrings(slice []string) []string { // StringGen generates a random string of a specified length and complexity // complexity: minimum percentage of special characters to be returned in the generated string (only impacts complex strings) func StringGen(length int, complex bool, complexity float64) string { - var extendedCharset string // hold extended character set used for complex strings var actualSpecialChars int // track the number of special characters in the generated string var minSpecialChars int // track the minimum number of special characters to accept charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // default character set used for all strings if complex { minSpecialChars = int(math.Round(float64(length) * complexity)) // determine minimum number of special characters to accept - extendedCharset = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~" charset = charset + extendedCharset - } else { - extendedCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" } // loop until a string of the desired complexity is generated