Skip to content

Commit

Permalink
Changed the value of set_cookie() 'expires' from 3x10**9 3x10**8 (10 …
Browse files Browse the repository at this point in the history
…years)

The initial value was triggering 2038 issues or some platforms (or pure
integer overflows, did not check). Also admit long as param type inside
set_cookie() as there does not seem to be any reason not to.
  • Loading branch information
medoc92 committed Jan 1, 2015
1 parent 9ed8494 commit 3504092
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ def set_cookie(self, name, value, secret=None, **options):
if key == 'expires':
if isinstance(value, (datedate, datetime)):
value = value.timetuple()
elif isinstance(value, (int, float)):
elif isinstance(value, (int, long, float)):
value = time.gmtime(value)
value = time.strftime("%a, %d %b %Y %H:%M:%S GMT", value)
self._cookies[name][key.replace('_', '-')] = value
Expand Down
4 changes: 2 additions & 2 deletions webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,10 @@ def settings():
def set():
config = get_config()
for k, v in DEFAULTS.items():
bottle.response.set_cookie(k, str(bottle.request.query.get(k)), max_age=3153600000, expires=3153600000)
bottle.response.set_cookie(k, str(bottle.request.query.get(k)), max_age=3153600000, expires=315360000)
for d in config['dirs']:
cookie_name = 'mount_%s' % urllib.quote(d, '')
bottle.response.set_cookie(cookie_name, str(bottle.request.query.get('mount_%s' % d)), max_age=3153600000, expires=3153600000)
bottle.response.set_cookie(cookie_name, str(bottle.request.query.get('mount_%s' % d)), max_age=3153600000, expires=315360000)
bottle.redirect('./')
#}}}
#{{{ osd
Expand Down

0 comments on commit 3504092

Please sign in to comment.