mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-02-03 08:04:07 +01:00
Web: Disable the fetch sandbox on Python versions with the _MAXHEADERS fix.
Partial fix to GH-1271.
This commit is contained in:
parent
0b93ab60a0
commit
9c57199838
@ -46,9 +46,11 @@ _ = PluginInternationalization('Web')
|
|||||||
if minisix.PY3:
|
if minisix.PY3:
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from html.entities import entitydefs
|
from html.entities import entitydefs
|
||||||
|
import http.client as http_client
|
||||||
else:
|
else:
|
||||||
from HTMLParser import HTMLParser
|
from HTMLParser import HTMLParser
|
||||||
from htmlentitydefs import entitydefs
|
from htmlentitydefs import entitydefs
|
||||||
|
import httplib as http_client
|
||||||
|
|
||||||
class Title(utils.web.HtmlToText):
|
class Title(utils.web.HtmlToText):
|
||||||
entitydefs = entitydefs.copy()
|
entitydefs = entitydefs.copy()
|
||||||
@ -90,7 +92,22 @@ class DelayedIrc:
|
|||||||
assert name not in ('reply', 'error', '_irc', '_msg', '_replies')
|
assert name not in ('reply', 'error', '_irc', '_msg', '_replies')
|
||||||
return getattr(self._irc, name)
|
return getattr(self._irc, name)
|
||||||
|
|
||||||
def fetch_sandbox(f):
|
if hasattr(http_client, '_MAXHEADERS'):
|
||||||
|
def fetch_sandbox(f):
|
||||||
|
"""Runs a command in a forked process with limited memory resources
|
||||||
|
to prevent memory bomb caused by specially crafted http responses.
|
||||||
|
|
||||||
|
On CPython versions with support for limiting the number of headers,
|
||||||
|
this is the identity function"""
|
||||||
|
return f
|
||||||
|
else:
|
||||||
|
# For the following CPython versions (as well as the matching Pypy
|
||||||
|
# versions):
|
||||||
|
# * 2.6 before 2.6.9
|
||||||
|
# * 2.7 before 2.7.9
|
||||||
|
# * 3.2 before 3.2.6
|
||||||
|
# * 3.3 before 3.3.3
|
||||||
|
def fetch_sandbox(f):
|
||||||
"""Runs a command in a forked process with limited memory resources
|
"""Runs a command in a forked process with limited memory resources
|
||||||
to prevent memory bomb caused by specially crafted http responses."""
|
to prevent memory bomb caused by specially crafted http responses."""
|
||||||
def process(self, irc, msg, *args, **kwargs):
|
def process(self, irc, msg, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user