1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
https://github.com/gcla/termshark/pull/170
From: Gilbert Ramirez <gram@alumni.rice.edu>
Date: Sun, 19 Oct 2025 10:55:04 -0500
Subject: [PATCH] Issue 169: With Wireshark 4.6.0, the column-title glossary changed
A third column is now possible, so the column-format initializer
needs to handle it. Also, since the output is a simple
tab-separated-value format, we don't need regular expressions to
parse it. We only need to split on tab characters.
--- a/pkg/shark/columnformat.go
+++ b/pkg/shark/columnformat.go
@@ -8,7 +8,6 @@ import (
"bufio"
"fmt"
"os/exec"
- "regexp"
"strconv"
"strings"
"sync"
@@ -239,8 +238,6 @@ func (w *ColumnsFromTshark) InitFromCache() error {
}
func (w *ColumnsFromTshark) InitNoCache() error {
- re := regexp.MustCompile("\\s+")
-
cmd := exec.Command(termshark.TSharkBin(), []string{"-G", "column-formats"}...)
out, err := cmd.StdoutPipe()
@@ -254,11 +251,17 @@ func (w *ColumnsFromTshark) InitNoCache() error {
scanner := bufio.NewScanner(out)
for scanner.Scan() {
- fields := re.Split(scanner.Text(), 2)
- if len(fields) == 2 && strings.HasPrefix(fields[0], "%") {
+ fields := strings.Split(scanner.Text(), "\t")
+
+ // Column 0: The format
+ // Column 1: The title of the column
+ // Column 2: The display filter field (optional)
+ if (len(fields) == 2 || len(fields) == 3) && strings.HasPrefix(fields[0], "%") {
+ // Remove trailing whitespace, if any
+ columnTitle := strings.TrimRight(fields[1], " ")
w.fields = append(w.fields, PsmlColumnSpec{
Field: PsmlField{Token: fields[0]},
- Name: fields[1],
+ Name: columnTitle,
})
}
}
|