Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion xdcc/xdcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,32 @@ func uint32ToIP(n int) net.IP {
return net.IPv4(a, b, c, d)
}

func splitCTCPFields(text string) []string {
var fields []string
inQuotes := false
current := strings.Builder{}

for _, r := range text {
switch r {
case '"':
inQuotes = !inQuotes
case ' ':
if inQuotes {
current.WriteRune(r)
} else if current.Len() > 0 {
fields = append(fields, current.String())
current.Reset()
}
default:
current.WriteRune(r)
}
}
if current.Len() > 0 {
fields = append(fields, current.String())
}
return fields
}

const XdccSendResArgs = 4

func (send *XdccSendRes) Name() string {
Expand Down Expand Up @@ -91,7 +117,7 @@ const (
)

func parseCTCPRes(text string) (CTCPResponse, error) {
fields := strings.Fields(text)
fields := splitCTCPFields(text)

var resp CTCPResponse = nil

Expand Down