1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00

Fixed data parsing bug

This commit is contained in:
sam 2012-04-26 16:56:13 +07:00
parent 2264d79d02
commit d1d455a41b
2 changed files with 9 additions and 13 deletions

View File

@ -87,7 +87,8 @@ class Paste(object):
comments = paste.read()[:-1] # remove the last coma
if expiration != u'burn_after_reading':
expiration = datetime.strptime(expiration, '%Y-%m-%d %H:%M:%S.%f')
expiration = datetime.strptime(expiration.strip(),
'%Y-%m-%d %H:%M:%S.%f')
except StopIteration:
raise TypeError(u'File %s is malformed' % path)

View File

@ -4,7 +4,8 @@ import os
import hashlib
import sys
from bottle import (Bottle, route, run, static_file, debug, view, request)
from bottle import (Bottle, route, run, abort,
static_file, debug, view, request)
import settings
@ -40,25 +41,19 @@ def create_paste():
return ''
@app.route('/paste/<paste_id>')
@app.route('/paste/:paste_id')
@view('paste')
def display_paste(paste_id):
try:
paste = Paste.load(paste_id)
except (TypeError, ValueError):
return ''
abort(404, u"This paste does't exist or has expired")
if content:
expiration = request.forms.get('expiration', u'burn_after_reading')
paste = Paste(expiration=expiration, content=content)
paste.save()
return paste.uuid
return ''
return {'paste': paste}
@app.route('/static/<filename:re:.*>')
@app.route('/static/<filename:path>')
def server_static(filename):
return static_file(filename, root=settings.STATIC_FILES_ROOT)