Skip to content

Commit 22bcc26

Browse files
committed
Allowed tags with more than 32 chars in rfc3164
1 parent e78ca33 commit 22bcc26

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

rfc3164/rfc3164.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ import (
66
"time"
77
)
88

9-
var (
10-
ErrTagTooLong = &syslogparser.ParserError{"Tag name too long"}
11-
)
12-
139
type Parser struct {
1410
buff []byte
1511
cursor int
@@ -183,20 +179,13 @@ func (p *Parser) parseTag() (string, error) {
183179
var tag []byte
184180
var err error
185181
var found bool
186-
var tooLong bool
187182

188183
from := p.cursor
189-
maxLen := from + 32
190184

191185
for {
192186
b = p.buff[p.cursor]
193187
bracketOpen = (b == '[')
194188
endOfTag = (b == ':' || b == ' ')
195-
tooLong = (p.cursor > maxLen)
196-
197-
if tooLong {
198-
return "", ErrTagTooLong
199-
}
200189

201190
// XXX : parse PID ?
202191
if bracketOpen {

rfc3164/rfc3164_test.go

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var (
2323
)
2424

2525
func (s *Rfc3164TestSuite) TestParser_Valid(c *C) {
26-
buff := []byte("<34>Oct 11 22:14:15 mymachine su: 'su root' failed for lonvick on /dev/pts/8")
26+
buff := []byte("<34>Oct 11 22:14:15 mymachine very.large.syslog.message.tag: 'su root' failed for lonvick on /dev/pts/8")
2727

2828
p := NewParser(buff)
2929
expectedP := &Parser{
@@ -43,7 +43,7 @@ func (s *Rfc3164TestSuite) TestParser_Valid(c *C) {
4343
expected := syslogparser.LogParts{
4444
"timestamp": time.Date(now.Year(), time.October, 11, 22, 14, 15, 0, time.UTC),
4545
"hostname": "mymachine",
46-
"tag": "su",
46+
"tag": "very.large.syslog.message.tag",
4747
"content": "'su root' failed for lonvick on /dev/pts/8",
4848
"priority": 34,
4949
"facility": 4,
@@ -122,17 +122,6 @@ func (s *Rfc3164TestSuite) TestParseTimestamp_Valid(c *C) {
122122
s.assertTimestamp(c, ts, buff, len(buff), nil)
123123
}
124124

125-
func (s *Rfc3164TestSuite) TestParseTag_TooLong(c *C) {
126-
// The TAG is a string of ABNF alphanumeric characters that MUST NOT exceed 32 characters.
127-
// Source : http://tools.ietf.org/html/rfc3164#section-4.1.3
128-
129-
aaa := "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
130-
buff := []byte(aaa + "[10]:")
131-
tag := ""
132-
133-
s.assertTag(c, tag, buff, len(aaa)+1, ErrTagTooLong)
134-
}
135-
136125
func (s *Rfc3164TestSuite) TestParseTag_Pid(c *C) {
137126
buff := []byte("apache2[10]:")
138127
tag := "apache2"

0 commit comments

Comments
 (0)