mirror of
https://github.com/rwinkhart/MUTN.git
synced 2026-08-28 04:46:41 -04:00
Fix complex strings failing to copy on Windows
This commit is contained in:
@@ -8,5 +8,7 @@ var ConfigDir = home + "/.config/libmutton"
|
|||||||
var ConfigPath = ConfigDir + "/libmutton.ini"
|
var ConfigPath = ConfigDir + "/libmutton.ini"
|
||||||
|
|
||||||
// PathSeparator defines the character used to separate directories in a path (platform-specific)
|
// PathSeparator defines the character used to separate directories in a path (platform-specific)
|
||||||
const PathSeparator = "/"
|
const (
|
||||||
const Windows = false // TODO temporary, remove after native sync is implemented
|
PathSeparator = "/"
|
||||||
|
Windows = false // TODO temporary, remove after native sync is implemented
|
||||||
|
)
|
||||||
|
|||||||
@@ -8,5 +8,7 @@ var ConfigDir = home + "\\AppData\\Local\\libmutton"
|
|||||||
var ConfigPath = ConfigDir + "\\libmutton.ini"
|
var ConfigPath = ConfigDir + "\\libmutton.ini"
|
||||||
|
|
||||||
// PathSeparator defines the character used to separate directories in a path (platform-specific)
|
// PathSeparator defines the character used to separate directories in a path (platform-specific)
|
||||||
const PathSeparator = "\\"
|
const (
|
||||||
const Windows = true // TODO temporary, remove after native sync is implemented
|
PathSeparator = "\\"
|
||||||
|
Windows = true // TODO temporary, remove after native sync is implemented
|
||||||
|
)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
// CopyField copies a field from an entry to the clipboard
|
// CopyField copies a field from an entry to the clipboard
|
||||||
func copyField(copySubject string, executableName string) {
|
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()
|
err := cmd.Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(AnsiError + "Failed to copy to clipboard: " + err.Error() + AnsiReset)
|
fmt.Println(AnsiError + "Failed to copy to clipboard: " + err.Error() + AnsiReset)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const extendedCharset = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
|
||||||
|
|
||||||
// TargetIsFile TargetStatusCheck checks if the targetLocation is a file, directory, or is inaccessible
|
// 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
|
// failCondition: 0 = fail on inaccessible, 1 = fail on inaccessible/file, 2 = fail on inaccessible/directory
|
||||||
// returns: isFile, isAccessible
|
// returns: isFile, isAccessible
|
||||||
@@ -93,17 +95,13 @@ func RemoveTrailingEmptyStrings(slice []string) []string {
|
|||||||
// StringGen generates a random string of a specified length and complexity
|
// 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)
|
// 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 {
|
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 actualSpecialChars int // track the number of special characters in the generated string
|
||||||
var minSpecialChars int // track the minimum number of special characters to accept
|
var minSpecialChars int // track the minimum number of special characters to accept
|
||||||
|
|
||||||
charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // default character set used for all strings
|
charset := "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" // default character set used for all strings
|
||||||
if complex {
|
if complex {
|
||||||
minSpecialChars = int(math.Round(float64(length) * complexity)) // determine minimum number of special characters to accept
|
minSpecialChars = int(math.Round(float64(length) * complexity)) // determine minimum number of special characters to accept
|
||||||
extendedCharset = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~"
|
|
||||||
charset = charset + extendedCharset
|
charset = charset + extendedCharset
|
||||||
} else {
|
|
||||||
extendedCharset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// loop until a string of the desired complexity is generated
|
// loop until a string of the desired complexity is generated
|
||||||
|
|||||||
Reference in New Issue
Block a user