X-Git-Url: https://git.llucax.com/software/blitiri.git/blobdiff_plain/464df08f44fddca976f584e5daaf538adc4f443d..87c41afd90655bb2c0bfb913457f73c59e0757e5:/blitiri.cgi diff --git a/blitiri.cgi b/blitiri.cgi index e69789f..f9663b5 100755 --- a/blitiri.cgi +++ b/blitiri.cgi @@ -423,7 +423,7 @@ def validate_rst(rst): except SystemMessage, e: desc = e.args[0].encode('utf-8') # the error string desc = desc[9:] # remove ":" - line = int(desc[:desc.find(':')]) # get just the line number + line = int(desc[:desc.find(':')] or 0) # get the line number desc = desc[desc.find(')')+2:-1] # remove (LEVEL/N) try: desc, context = desc.split('\n', 1) @@ -1109,7 +1109,8 @@ def handle_cgi(): render_artlist(articles, db) elif comment: form_data = CommentFormData(author.strip().replace('\n', ' '), - link.strip().replace('\n', ' '), captcha, body) + link.strip().replace('\n', ' '), captcha, + body.replace('\r', '')) article = db.get_article(uuid) captcha = Captcha(article) redirect = False @@ -1135,8 +1136,10 @@ def handle_cgi(): error = validate_rst(form_data.body) if error is not None: (line, desc, ctx) = error - form_data.body_error = 'error at line %d: %s' \ - % (line, desc) + at = '' + if line: + at = ' at line %d' % line + form_data.body_error = 'error%s: %s' % (at, desc) valid = False if valid: c = article.add_comment(form_data.author,