Skip to content

Commit de19dfc

Browse files
committed
handle zero-expiry session cookies in filters and display
1 parent 136923b commit de19dfc

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

cmd/kooky/kooky.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func prCookieLine(w io.Writer, cookie *kooky.Cookie, trimLen int) {
100100
trimStr(cookie.Name, trimLen),
101101
// be careful about raw bytes
102102
trimStr(strings.Trim(fmt.Sprintf(`%q`, cookie.Value), `"`), trimLen),
103-
cookie.Expires.Format(`2006.01.02 15:04:05`),
103+
prExpires(cookie),
104104
)
105105
}
106106

@@ -118,6 +118,13 @@ func prProfile(c *kooky.Cookie) string {
118118
return c.Browser.Profile()
119119
}
120120

121+
func prExpires(c *kooky.Cookie) string {
122+
if c == nil || c.Expires.IsZero() {
123+
return `-`
124+
}
125+
return c.Expires.Format(`2006.01.02 15:04:05`)
126+
}
127+
121128
func prFilePath(c *kooky.Cookie) string {
122129
if c == nil || c.Browser == nil {
123130
return ``

filter.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ var HTTPOnly Filter = FilterFunc(func(cookie *Cookie) bool {
325325
// expires filters
326326

327327
var Valid Filter = ValueFilterFunc(func(cookie *Cookie) bool {
328-
return cookie != nil && cookie.Expires.After(time.Now()) && cookie.Cookie.Valid() == nil
328+
return cookie != nil && (cookie.Expires.IsZero() || cookie.Expires.After(time.Now())) && cookie.Cookie.Valid() == nil
329329
})
330330

331331
var Expired Filter = FilterFunc(func(cookie *Cookie) bool {
332-
return cookie != nil && cookie.Expires.Before(time.Now())
332+
return cookie != nil && !cookie.Expires.IsZero() && cookie.Expires.Before(time.Now())
333333
})
334334

335335
func ExpiresAfter(u time.Time) Filter {

0 commit comments

Comments
 (0)