Skip to content

Commit

Permalink
Handle special characters in the command output
Browse files Browse the repository at this point in the history
  • Loading branch information
anujva committed Jan 18, 2023
1 parent b292a1d commit 0fc0633
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ func getApplicationData(context context.T, command string, args []string) (data
log.Debugf("Command Stderr: %v", string(output))
err = fmt.Errorf("Command failed with error: %v", string(output))
} else {
cmdOutput := string(output)
cmdOutputRaw := string(output)
cmdOutput := handleCtrlChars(cmdOutputRaw)
// parse snap result
if command == "snap" {
cmdOutput = parseSnapOutput(context, cmdOutput)
Expand All @@ -348,6 +349,10 @@ func getApplicationData(context context.T, command string, args []string) (data
return
}

func handleCtrlChars(s string) string {
return strings.Replace(s, "\x0D", "", -1)
}

// convertToApplicationData converts query output into json string so that it can be deserialized easily
func convertToApplicationData(input string) (data []model.ApplicationData, err error) {

Expand Down

0 comments on commit 0fc0633

Please sign in to comment.