Fix current flakes.

This commit is contained in:
Jelmer Vernooij 2018-11-03 14:50:22 +00:00
parent 62ddcba701
commit 63cc15a962
No known key found for this signature in database
GPG Key ID: 579C160D4C9E23E8
10 changed files with 22 additions and 20 deletions

View File

@ -26,7 +26,7 @@ except pkg_resources.DistributionNotFound:
dist = type("I'm a Version", (object, ), {}) dist = type("I'm a Version", (object, ), {})
with io.open(join(dirname(__file__), "../setup.py")) as fp: with io.open(join(dirname(__file__), "../setup.py")) as fp:
for line in fp: for line in fp:
m = re.match("\s*version='([^']+)'\s*", line) m = re.match("\\s*version='([^']+)'\\s*", line)
if m: if m:
dist.version = m.group(1) dist.version = m.group(1)
break break

5
docs/releasing.rst Normal file
View File

@ -0,0 +1,5 @@
Releasing steps
===============
* Run ``make check``, ``python3 setup.py nosetests``, ``python2 setup.py nosetests``
* Update version number in ``setup.py`` and ``CHANGES.rst``

View File

@ -38,7 +38,7 @@ def timedelta(string):
""" """
keys = ["weeks", "days", "hours", "minutes", "seconds"] keys = ["weeks", "days", "hours", "minutes", "seconds"]
regex = "".join(["((?P<%s>\d+)%s ?)?" % (k, k[0]) for k in keys]) regex = "".join(["((?P<%s>\\d+)%s ?)?" % (k, k[0]) for k in keys])
kwargs = {} kwargs = {}
for k, v in re.match(regex, string).groupdict(default="0").items(): for k, v in re.match(regex, string).groupdict(default="0").items():
kwargs[k] = int(v) kwargs[k] = int(v)

View File

@ -37,7 +37,7 @@ class Comments:
' notification INTEGER DEFAULT 0);']) ' notification INTEGER DEFAULT 0);'])
try: try:
self.db.execute(['ALTER TABLE comments ADD COLUMN notification INTEGER DEFAULT 0;']) self.db.execute(['ALTER TABLE comments ADD COLUMN notification INTEGER DEFAULT 0;'])
except: except Exception:
pass pass
def add(self, uri, c): def add(self, uri, c):
@ -137,8 +137,7 @@ class Comments:
for f in fields_comments]) for f in fields_comments])
sql_threads_fields = ', '.join(['threads.' + f sql_threads_fields = ', '.join(['threads.' + f
for f in fields_threads]) for f in fields_threads])
sql = ['SELECT ' + sql_comments_fields + ', ' + sql = ['SELECT ' + sql_comments_fields + ', ' + sql_threads_fields + ' '
sql_threads_fields + ' '
'FROM comments INNER JOIN threads ' 'FROM comments INNER JOIN threads '
'ON comments.tid=threads.id ' 'ON comments.tid=threads.id '
'WHERE comments.mode = ? '] 'WHERE comments.mode = ? ']

View File

@ -69,6 +69,7 @@ class SMTPConnection(object):
def __exit__(self, exc_type, exc_value, traceback): def __exit__(self, exc_type, exc_value, traceback):
self.client.quit() self.client.quit()
class SMTP(object): class SMTP(object):
def __init__(self, isso): def __init__(self, isso):
@ -165,7 +166,7 @@ class SMTP(object):
for comment_to_notify in comments_to_notify: for comment_to_notify in comments_to_notify:
email = comment_to_notify["email"] email = comment_to_notify["email"]
if "email" in comment_to_notify and comment_to_notify["notification"] and email not in notified \ if "email" in comment_to_notify and comment_to_notify["notification"] and email not in notified \
and comment_to_notify["id"] != comment["id"] and email != comment["email"]: and comment_to_notify["id"] != comment["id"] and email != comment["email"]:
body = self.format(thread, comment, parent_comment, email, admin=False) body = self.format(thread, comment, parent_comment, email, admin=False)
subject = "Re: New comment posted on %s" % thread["title"] subject = "Re: New comment posted on %s" % thread["title"]
self.sendmail(subject, body, thread, comment, to=email) self.sendmail(subject, body, thread, comment, to=email)

View File

@ -248,7 +248,7 @@ class WordPress(object):
@classmethod @classmethod
def detect(cls, peek): def detect(cls, peek):
return re.compile("http://wordpress.org/export/(1\.\d)/").search(peek) return re.compile("http://wordpress.org/export/(1\\.\\d)/").search(peek)
class Generic(object): class Generic(object):

View File

@ -352,7 +352,7 @@ class TestComments(unittest.TestCase):
self.assertEqual(rv.status_code, 200) self.assertEqual(rv.status_code, 200)
self.assertEqual(rv.headers['ETag'], '"1-2"') self.assertEqual(rv.headers['ETag'], '"1-2"')
data = rv.data.decode('utf-8') data = rv.data.decode('utf-8')
data = re.sub('[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+Z', data = re.sub('[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]+Z',
'2018-04-01T10:00:00Z', data) '2018-04-01T10:00:00Z', data)
self.assertEqual(data, """<?xml version=\'1.0\' encoding=\'utf-8\'?> self.assertEqual(data, """<?xml version=\'1.0\' encoding=\'utf-8\'?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"><updated>2018-04-01T10:00:00Z</updated><id>tag:example.org,2018:/isso/thread/path/</id><title>Comments for example.org/path/</title><entry><id>tag:example.org,2018:/isso/1/2</id><title>Comment #2</title><updated>2018-04-01T10:00:00Z</updated><author><name /></author><link href="https://example.org/path/#isso-2" /><content type="html">&lt;p&gt;&lt;em&gt;Second&lt;/em&gt;&lt;/p&gt;</content><thr:in-reply-to href="https://example.org/path/#isso-1" ref="tag:example.org,2018:/isso/1/1" /></entry><entry><id>tag:example.org,2018:/isso/1/1</id><title>Comment #1</title><updated>2018-04-01T10:00:00Z</updated><author><name /></author><link href="https://example.org/path/#isso-1" /><content type="html">&lt;p&gt;First&lt;/p&gt;</content></entry></feed>""") <feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0"><updated>2018-04-01T10:00:00Z</updated><id>tag:example.org,2018:/isso/thread/path/</id><title>Comments for example.org/path/</title><entry><id>tag:example.org,2018:/isso/1/2</id><title>Comment #2</title><updated>2018-04-01T10:00:00Z</updated><author><name /></author><link href="https://example.org/path/#isso-2" /><content type="html">&lt;p&gt;&lt;em&gt;Second&lt;/em&gt;&lt;/p&gt;</content><thr:in-reply-to href="https://example.org/path/#isso-1" ref="tag:example.org,2018:/isso/1/1" /></entry><entry><id>tag:example.org,2018:/isso/1/1</id><title>Comment #1</title><updated>2018-04-01T10:00:00Z</updated><author><name /></author><link href="https://example.org/path/#isso-1" /><content type="html">&lt;p&gt;First&lt;/p&gt;</content></entry></feed>""")

View File

@ -16,7 +16,7 @@ except ImportError:
def pbkdf2(val, salt, iterations, dklen, func): def pbkdf2(val, salt, iterations, dklen, func):
return _pbkdf2(val, salt, iterations, dklen, ("hmac-" + func).encode("utf-8")) return _pbkdf2(val, salt, iterations, dklen, ("hmac-" + func).encode("utf-8"))
except ImportError as ex: except ImportError as ex:
raise ImportError("No PBKDF2 implementation found. Either upgrade " + raise ImportError("No PBKDF2 implementation found. Either upgrade "
"to `werkzeug` 0.9 or install `passlib`.") "to `werkzeug` 0.9 or install `passlib`.")

View File

@ -15,19 +15,16 @@ class Sanitizer(object):
# #
# [1] https://github.com/vmg/sundown/blob/master/html/html.c # [1] https://github.com/vmg/sundown/blob/master/html/html.c
self.elements = ["a", "p", "hr", "br", "ol", "ul", "li", self.elements = ["a", "p", "hr", "br", "ol", "ul", "li",
"pre", "code", "blockquote", "pre", "code", "blockquote",
"del", "ins", "strong", "em", "del", "ins", "strong", "em",
"h1", "h2", "h3", "h4", "h5", "h6", "h1", "h2", "h3", "h4", "h5", "h6",
"table", "thead", "tbody", "th", "td"] + elements "table", "thead", "tbody", "th", "td"] + elements
# href for <a> and align for <table> # href for <a> and align for <table>
self.attributes = ["align", "href"] + attributes self.attributes = ["align", "href"] + attributes
def sanitize(self, text): def sanitize(self, text):
clean_html = bleach.clean(text, tags=self.elements, clean_html = bleach.clean(text, tags=self.elements, attributes=self.attributes, strip=True)
attributes=self.attributes, strip=True)
def set_links(attrs, new=False): def set_links(attrs, new=False):
href_key = (None, u'href') href_key = (None, u'href')

View File

@ -1091,9 +1091,9 @@ class API(object):
data = self.isso.unsign(req.cookies.get('admin-session', ''), data = self.isso.unsign(req.cookies.get('admin-session', ''),
max_age=60 * 60 * 24) max_age=60 * 60 * 24)
except BadSignature: except BadSignature:
return render_template('login.html',isso_host_script=isso_host_script) return render_template('login.html', isso_host_script=isso_host_script)
if not data or not data['logged']: if not data or not data['logged']:
return render_template('login.html',isso_host_script=isso_host_script) return render_template('login.html', isso_host_script=isso_host_script)
page_size = 100 page_size = 100
page = int(req.args.get('page', 0)) page = int(req.args.get('page', 0))
order_by = req.args.get('order_by', None) order_by = req.args.get('order_by', None)