fix: filter out non-printable characters in process line
Otherwise the output might be distorted by characters like `\n`. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com> (cherry picked from commit 8166a58b364f760212b2a610ce0d764b8b4c5c46)
This commit is contained in:
parent
70d3c91fb7
commit
c8dedbe116
@ -178,6 +178,7 @@ var cpu = func(p1, p2 *machineapi.ProcessInfo) bool {
|
||||
return p1.CpuTime > p2.CpuTime
|
||||
}
|
||||
|
||||
//nolint:gocyclo
|
||||
func processesOutput(ctx context.Context, c *client.Client) (output string, err error) {
|
||||
var remotePeer peer.Peer
|
||||
|
||||
@ -214,6 +215,15 @@ func processesOutput(ctx context.Context, c *client.Client) (output string, err
|
||||
args = p.Args
|
||||
}
|
||||
|
||||
// filter out non-printable characters
|
||||
args = strings.Map(func(r rune) rune {
|
||||
if r < 32 || r > 126 {
|
||||
return ' '
|
||||
}
|
||||
|
||||
return r
|
||||
}, args)
|
||||
|
||||
node := defaultNode
|
||||
|
||||
if msg.Metadata != nil {
|
||||
|
@ -50,6 +50,8 @@ func NewProcessTable() *ProcessTable {
|
||||
}
|
||||
|
||||
// OnAPIDataChange implements the APIDataListener interface.
|
||||
//
|
||||
//nolint:gocyclo
|
||||
func (widget *ProcessTable) OnAPIDataChange(node string, data *apidata.Data) {
|
||||
nodeData := data.Nodes[node]
|
||||
|
||||
@ -97,6 +99,15 @@ func (widget *ProcessTable) OnAPIDataChange(node string, data *apidata.Data) {
|
||||
args = proc.Args
|
||||
}
|
||||
|
||||
// filter out non-printable characters
|
||||
args = strings.Map(func(r rune) rune {
|
||||
if r < 32 || r > 126 {
|
||||
return ' '
|
||||
}
|
||||
|
||||
return r
|
||||
}, args)
|
||||
|
||||
line := fmt.Sprintf("%7d %s %6.1f %6.1f %8s %8s %10s %4d %s",
|
||||
proc.GetPid(),
|
||||
proc.State,
|
||||
|
Loading…
x
Reference in New Issue
Block a user