[ckan-changes] commit/ckan: dread: [misc, tests]: #1180 handle another type of spam link better in markdown.
Bitbucket
commits-noreply at bitbucket.org
Wed Jun 15 12:37:29 UTC 2011
1 new changeset in ckan:
http://bitbucket.org/okfn/ckan/changeset/2fb519cb06d7/
changeset: 2fb519cb06d7
branch: release-v1.4.1
user: dread
date: 2011-06-15 14:10:21
summary: [misc,tests]: #1180 handle another type of spam link better in markdown.
affected #: 3 files (1016 bytes)
--- a/ckan/controllers/group.py Tue Jun 14 12:44:51 2011 +0100
+++ b/ckan/controllers/group.py Wed Jun 15 13:10:21 2011 +0100
@@ -72,7 +72,11 @@
import ckan.misc
format = ckan.misc.MarkdownFormat()
desc_formatted = format.to_html(c.group.description)
- desc_formatted = genshi.HTML(desc_formatted)
+ try:
+ desc_formatted = genshi.HTML(desc_formatted)
+ except genshi.ParseError, e:
+ log.error('Could not print group description: %r Error: %r', c.group.description, e)
+ desc_formatted = 'Error: Could not parse group description'
c.group_description_formatted = desc_formatted
c.group_admins = self.authorizer.get_admins(c.group)
--- a/ckan/controllers/user.py Tue Jun 14 12:44:51 2011 +0100
+++ b/ckan/controllers/user.py Wed Jun 15 13:10:21 2011 +0100
@@ -1,4 +1,5 @@
import re
+import logging
import genshi
from sqlalchemy import or_, func, desc
@@ -6,6 +7,8 @@
import ckan.misc
from ckan.lib.base import *
+log = logging.getLogger(__name__)
+
def login_form():
return render('user/login_form.html').replace('FORM_ACTION', '%s')
@@ -164,8 +167,13 @@
def _format_about(self, about):
about_formatted = ckan.misc.MarkdownFormat().to_html(about)
- return genshi.HTML(about_formatted)
-
+ try:
+ html = genshi.HTML(about_formatted)
+ except genshi.ParseError, e:
+ log.error('Could not print "about" field Field: %r Error: %r', about, e)
+ html = 'Error: Could not parse About text'
+ return html
+
def _get_form_password(self):
password1 = request.params.getone('password1')
password2 = request.params.getone('password2')
--- a/ckan/tests/functional/test_user.py Tue Jun 14 12:44:51 2011 +0100
+++ b/ckan/tests/functional/test_user.py Wed Jun 15 13:10:21 2011 +0100
@@ -21,6 +21,7 @@
CreateTestData.create_user('unfinisher', about='<a href="http://unfinished.tag')
CreateTestData.create_user('uncloser', about='<a href="http://unclosed.tag">')
CreateTestData.create_user('spammer', about=u'<a href="http://mysite">mysite</a><a href=\u201dhttp://test2\u201d>test2</a>')
+ CreateTestData.create_user('spammer2', about=u'<a href="http://spamsite1.com\u201d>spamsite1</a>\r\n<a href="http://www.spamsite2.com\u201d>spamsite2</a>\r\n')
@classmethod
def teardown_class(self):
@@ -98,6 +99,15 @@
'href="TAG MALFORMED"',
'target="_blank"',
'rel="nofollow"')
+
+ def test_user_read_about_spam2(self):
+ user = model.User.by_name(u'spammer2')
+ offset = '/user/%s' % user.id
+ res = self.app.get(offset, status=200)
+ main_res = self.main_div(res)
+ assert 'spammer2' in res, res
+ assert 'spamsite2' not in res, res
+ assert 'Error: Could not parse About text' in res, res
def test_user_login(self):
offset = url_for(controller='user', action='login', id=None)
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list