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
|
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.
|
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
|
- 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
|
- add localStorage fallback if QUOTA_EXCEEDED_ERR is thrown (e.g. Safari
|
||||||
private browsing)
|
private browsing)
|
||||||
|
|
||||||
- new Bulgarian translation by sahwar, new Swedish translation by <Gustav
|
- add '--empty-id' flag to Disqus import, because Disqus' export sucks
|
||||||
Näslund, #143
|
|
||||||
|
|
||||||
- add --emptyid flag to import strange Disqus exports, #135
|
- (re)gain compatibility with Werkzeug 0.8 and really old html5lib versions
|
||||||
|
available in Debian Squeeze, #170 & #168
|
||||||
.. __: https://www.python.org/dev/peps/pep-0466/
|
|
||||||
|
|
||||||
|
- add User-Agent when Isso requests the URL, an alternate way to #151 (add
|
||||||
|
'X-Isso' when requesting).
|
||||||
|
|
||||||
0.9.8 (2014-10-08)
|
0.9.8 (2014-10-08)
|
||||||
------------------
|
------------------
|
||||||
|
@ -48,6 +48,9 @@ from os.path import dirname, join
|
|||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from functools import partial, reduce
|
from functools import partial, reduce
|
||||||
|
|
||||||
|
import pkg_resources
|
||||||
|
werkzeug = pkg_resources.get_distribution("werkzeug")
|
||||||
|
|
||||||
from itsdangerous import URLSafeTimedSerializer
|
from itsdangerous import URLSafeTimedSerializer
|
||||||
|
|
||||||
from werkzeug.routing import Map
|
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"),
|
allowed=("Origin", "Referer", "Content-Type"),
|
||||||
exposed=("X-Set-Cookie", "Date")))
|
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)
|
return reduce(lambda x, f: f(x), wrapper, isso)
|
||||||
|
|
||||||
|
@ -70,9 +70,14 @@ class SMTP(object):
|
|||||||
else:
|
else:
|
||||||
self.client.starttls()
|
self.client.starttls()
|
||||||
|
|
||||||
if self.conf.get('username') and self.conf.get('password'):
|
username = self.conf.get('username')
|
||||||
self.client.login(self.conf.get('username').encode('ascii', errors='ignore'),
|
password = self.conf.get('password')
|
||||||
self.conf.get('password').encode('ascii', errors='ignore'))
|
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
|
return self.client
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
define({
|
define({
|
||||||
"postbox-text": "Комментировать здесь (миниум 3 символа)",
|
"postbox-text": "Комментировать здесь (минимум 3 символа)",
|
||||||
"postbox-author": "Имя (необязательно)",
|
"postbox-author": "Имя (необязательно)",
|
||||||
"postbox-email": "Email (необязательно)",
|
"postbox-email": "Email (необязательно)",
|
||||||
"postbox-submit": "Отправить",
|
"postbox-submit": "Отправить",
|
||||||
|
@ -63,7 +63,7 @@ class TestHTML(unittest.TestCase):
|
|||||||
print("Hello, World")
|
print("Hello, World")
|
||||||
</code></pre>""")
|
</code></pre>""")
|
||||||
|
|
||||||
@unittest.skipIf(html.html5lib_version == "0.95", "backport")
|
@unittest.skipIf(html.HTML5LIB_VERSION <= html.HTML5LIB_SIMPLETREE, "backport")
|
||||||
def test_sanitizer(self):
|
def test_sanitizer(self):
|
||||||
sanitizer = html.Sanitizer(elements=[], attributes=[])
|
sanitizer = html.Sanitizer(elements=[], attributes=[])
|
||||||
examples = [
|
examples = [
|
||||||
@ -76,7 +76,7 @@ class TestHTML(unittest.TestCase):
|
|||||||
for (input, expected) in examples:
|
for (input, expected) in examples:
|
||||||
self.assertEqual(html.sanitize(sanitizer, input), expected)
|
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):
|
def test_sanitizer_extensions(self):
|
||||||
sanitizer = html.Sanitizer(elements=["img"], attributes=["src"])
|
sanitizer = html.Sanitizer(elements=["img"], attributes=["src"])
|
||||||
examples = [
|
examples = [
|
||||||
|
@ -2,14 +2,17 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import pkg_resources
|
|
||||||
import operator
|
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
|
from isso.compat import reduce
|
||||||
|
|
||||||
import html5lib
|
import html5lib
|
||||||
html5lib_version = pkg_resources.get_distribution("html5lib").version
|
|
||||||
|
|
||||||
from html5lib.sanitizer import HTMLSanitizer
|
from html5lib.sanitizer import HTMLSanitizer
|
||||||
from html5lib.serializer import HTMLSerializer
|
from html5lib.serializer import HTMLSerializer
|
||||||
|
|
||||||
@ -45,7 +48,11 @@ def sanitize(tokenizer, document):
|
|||||||
parser = html5lib.HTMLParser(tokenizer=tokenizer)
|
parser = html5lib.HTMLParser(tokenizer=tokenizer)
|
||||||
domtree = parser.parseFragment(document)
|
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)
|
stream = html5lib.treewalkers.getTreeWalker(builder)(domtree)
|
||||||
serializer = HTMLSerializer(quote_attr_values=True, omit_optional_tags=False)
|
serializer = HTMLSerializer(quote_attr_values=True, omit_optional_tags=False)
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
import http.client as httplib
|
import http.client as httplib
|
||||||
|
|
||||||
|
from isso import dist
|
||||||
from isso.wsgi import urlsplit
|
from isso.wsgi import urlsplit
|
||||||
|
|
||||||
|
|
||||||
@ -21,6 +22,10 @@ class curl(object):
|
|||||||
return resp.status
|
return resp.status
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
"User-Agent": "Isso/{0} (+http://posativ.org/isso)".format(dist.version)
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, method, host, path, timeout=3):
|
def __init__(self, method, host, path, timeout=3):
|
||||||
self.method = method
|
self.method = method
|
||||||
self.host = host
|
self.host = host
|
||||||
@ -35,13 +40,13 @@ class curl(object):
|
|||||||
self.con = http(host, port, timeout=self.timeout)
|
self.con = http(host, port, timeout=self.timeout)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.con.request(self.method, self.path)
|
self.con.request(self.method, self.path, headers=self.headers)
|
||||||
except (httplib.HTTPException, socket.error):
|
except (httplib.HTTPException, socket.error):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return self.con.getresponse()
|
return self.con.getresponse()
|
||||||
except (socket.timeout, socket.error):
|
except (httplib.HTTPException, socket.timeout, socket.error):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_value, traceback):
|
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
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import sys
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -149,6 +150,27 @@ class CORSMiddleware(object):
|
|||||||
return self.app(environ, add_cors_headers)
|
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):
|
class Request(_Request):
|
||||||
|
|
||||||
# Assuming UTF-8, comments with 65536 characters would consume
|
# Assuming UTF-8, comments with 65536 characters would consume
|
||||||
|
Loading…
Reference in New Issue
Block a user