Merge branch 'legacy/0.9'
Conflicts: CHANGES.rst isso/ext/notifications.py isso/utils/http.py setup.py
This commit is contained in:
commit
630e76f66c
21
CHANGES.rst
21
CHANGES.rst
@ -24,18 +24,29 @@ Changelog for Isso
|
||||
Intra emphasis would compile `foo_bar_baz` to foo<em>bar</em>baz. This
|
||||
behavior is very confusing for users not knowing the Markdown spec in detail.
|
||||
|
||||
- new Bulgarian translation by sahwar, new Swedish translation by <Gustav
|
||||
Näslund, #143
|
||||
|
||||
.. __: https://www.python.org/dev/peps/pep-0466/
|
||||
|
||||
|
||||
0.9.9 (2015-03-04)
|
||||
------------------
|
||||
|
||||
- several Python 3.x related bugfixes
|
||||
|
||||
- don't lose comment form if the server rejected the POST request, #144
|
||||
|
||||
- add localStorage fallback if QUOTA_EXCEEDED_ERR is thrown (e.g. Safari
|
||||
private browsing)
|
||||
|
||||
- new Bulgarian translation by sahwar, new Swedish translation by <Gustav
|
||||
Näslund, #143
|
||||
- add '--empty-id' flag to Disqus import, because Disqus' export sucks
|
||||
|
||||
- add --emptyid flag to import strange Disqus exports, #135
|
||||
|
||||
.. __: https://www.python.org/dev/peps/pep-0466/
|
||||
- (re)gain compatibility with Werkzeug 0.8 and really old html5lib versions
|
||||
available in Debian Squeeze, #170 & #168
|
||||
|
||||
- add User-Agent when Isso requests the URL, an alternate way to #151 (add
|
||||
'X-Isso' when requesting).
|
||||
|
||||
0.9.8 (2014-10-08)
|
||||
------------------
|
||||
|
@ -48,6 +48,9 @@ from os.path import dirname, join
|
||||
from argparse import ArgumentParser
|
||||
from functools import partial, reduce
|
||||
|
||||
import pkg_resources
|
||||
werkzeug = pkg_resources.get_distribution("werkzeug")
|
||||
|
||||
from itsdangerous import URLSafeTimedSerializer
|
||||
|
||||
from werkzeug.routing import Map
|
||||
@ -191,7 +194,10 @@ def make_app(conf=None, threading=True, multiprocessing=False, uwsgi=False):
|
||||
allowed=("Origin", "Referer", "Content-Type"),
|
||||
exposed=("X-Set-Cookie", "Date")))
|
||||
|
||||
wrapper.extend([wsgi.SubURI, ProxyFix])
|
||||
wrapper.extend([wsgi.SubURI, ProxyFix, wsgi.LegacyWerkzeugMiddleware])
|
||||
|
||||
if werkzeug.version.startswith("0.8"):
|
||||
wrapper.append(wsgi.LegacyWerkzeugMiddleware)
|
||||
|
||||
return reduce(lambda x, f: f(x), wrapper, isso)
|
||||
|
||||
|
@ -70,9 +70,14 @@ class SMTP(object):
|
||||
else:
|
||||
self.client.starttls()
|
||||
|
||||
if self.conf.get('username') and self.conf.get('password'):
|
||||
self.client.login(self.conf.get('username').encode('ascii', errors='ignore'),
|
||||
self.conf.get('password').encode('ascii', errors='ignore'))
|
||||
username = self.conf.get('username')
|
||||
password = self.conf.get('password')
|
||||
if username is not None and password is not None:
|
||||
if PY2K:
|
||||
username = username.encode('ascii')
|
||||
password = password.encode('ascii')
|
||||
|
||||
self.client.login(username, password)
|
||||
|
||||
return self.client
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
define({
|
||||
"postbox-text": "Комментировать здесь (миниум 3 символа)",
|
||||
"postbox-text": "Комментировать здесь (минимум 3 символа)",
|
||||
"postbox-author": "Имя (необязательно)",
|
||||
"postbox-email": "Email (необязательно)",
|
||||
"postbox-submit": "Отправить",
|
||||
|
@ -63,7 +63,7 @@ class TestHTML(unittest.TestCase):
|
||||
print("Hello, World")
|
||||
</code></pre>""")
|
||||
|
||||
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
|
||||
@unittest.skipIf(html.HTML5LIB_VERSION <= html.HTML5LIB_SIMPLETREE, "backport")
|
||||
def test_sanitizer(self):
|
||||
sanitizer = html.Sanitizer(elements=[], attributes=[])
|
||||
examples = [
|
||||
@ -76,7 +76,7 @@ class TestHTML(unittest.TestCase):
|
||||
for (input, expected) in examples:
|
||||
self.assertEqual(html.sanitize(sanitizer, input), expected)
|
||||
|
||||
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
|
||||
@unittest.skipIf(html.HTML5LIB_VERSION <= html.HTML5LIB_SIMPLETREE, "backport")
|
||||
def test_sanitizer_extensions(self):
|
||||
sanitizer = html.Sanitizer(elements=["img"], attributes=["src"])
|
||||
examples = [
|
||||
|
@ -2,14 +2,17 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import pkg_resources
|
||||
import operator
|
||||
import pkg_resources
|
||||
|
||||
from distutils.version import LooseVersion as Version
|
||||
|
||||
HTML5LIB_VERSION = Version(pkg_resources.get_distribution("html5lib").version)
|
||||
HTML5LIB_SIMPLETREE = Version("0.95")
|
||||
|
||||
from isso.compat import reduce
|
||||
|
||||
import html5lib
|
||||
html5lib_version = pkg_resources.get_distribution("html5lib").version
|
||||
|
||||
from html5lib.sanitizer import HTMLSanitizer
|
||||
from html5lib.serializer import HTMLSerializer
|
||||
|
||||
@ -45,7 +48,11 @@ def sanitize(tokenizer, document):
|
||||
parser = html5lib.HTMLParser(tokenizer=tokenizer)
|
||||
domtree = parser.parseFragment(document)
|
||||
|
||||
builder = "simpletree" if html5lib_version == "0.95" else "etree"
|
||||
if HTML5LIB_VERSION > HTML5LIB_SIMPLETREE:
|
||||
builder = "etree"
|
||||
else:
|
||||
builder = "simpletree"
|
||||
|
||||
stream = html5lib.treewalkers.getTreeWalker(builder)(domtree)
|
||||
serializer = HTMLSerializer(quote_attr_values=True, omit_optional_tags=False)
|
||||
|
||||
|
@ -7,6 +7,7 @@ try:
|
||||
except ImportError:
|
||||
import http.client as httplib
|
||||
|
||||
from isso import dist
|
||||
from isso.wsgi import urlsplit
|
||||
|
||||
|
||||
@ -21,6 +22,10 @@ class curl(object):
|
||||
return resp.status
|
||||
"""
|
||||
|
||||
headers = {
|
||||
"User-Agent": "Isso/{0} (+http://posativ.org/isso)".format(dist.version)
|
||||
}
|
||||
|
||||
def __init__(self, method, host, path, timeout=3):
|
||||
self.method = method
|
||||
self.host = host
|
||||
@ -35,13 +40,13 @@ class curl(object):
|
||||
self.con = http(host, port, timeout=self.timeout)
|
||||
|
||||
try:
|
||||
self.con.request(self.method, self.path)
|
||||
self.con.request(self.method, self.path, headers=self.headers)
|
||||
except (httplib.HTTPException, socket.error):
|
||||
return None
|
||||
|
||||
try:
|
||||
return self.con.getresponse()
|
||||
except (socket.timeout, socket.error):
|
||||
except (httplib.HTTPException, socket.timeout, socket.error):
|
||||
return None
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
|
22
isso/wsgi.py
22
isso/wsgi.py
@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
import socket
|
||||
|
||||
try:
|
||||
@ -149,6 +150,27 @@ class CORSMiddleware(object):
|
||||
return self.app(environ, add_cors_headers)
|
||||
|
||||
|
||||
class LegacyWerkzeugMiddleware(object):
|
||||
# Add compatibility with werkzeug 0.8
|
||||
# -- https://github.com/posativ/isso/pull/170
|
||||
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
|
||||
def __call__(self, environ, start_response):
|
||||
|
||||
def to_native(x, charset=sys.getdefaultencoding(), errors='strict'):
|
||||
if x is None or isinstance(x, str):
|
||||
return x
|
||||
return x.decode(charset, errors)
|
||||
|
||||
def fix_headers(status, headers, exc_info=None):
|
||||
headers = [(to_native(key), value) for key, value in headers]
|
||||
return start_response(status, headers, exc_info)
|
||||
|
||||
return self.app(environ, fix_headers)
|
||||
|
||||
|
||||
class Request(_Request):
|
||||
|
||||
# Assuming UTF-8, comments with 65536 characters would consume
|
||||
|
Loading…
Reference in New Issue
Block a user