core: use application wide detection of invalid bytes sent via URL/GET/POST data.

This commit is contained in:
Marcin Kuzminski 2018-10-24 12:29:11 +02:00
parent 00ec168f83
commit 8d8e2802da
3 changed files with 95 additions and 16 deletions

View file

@ -27,7 +27,6 @@ import subprocess32
from dateutil.parser import parse
from pyramid.httpexceptions import HTTPBadRequest
from pyramid.threadlocal import get_current_request
from pyramid.interfaces import IRoutesMapper
from pyramid.settings import asbool
@ -39,7 +38,6 @@ from rhodecode.config.jsroutes import generate_jsroutes_content
from rhodecode.lib import auth
from rhodecode.lib.base import get_auth_user
import rhodecode
@ -61,19 +59,7 @@ def add_renderer_globals(event):
def add_localizer(event):
request = event.request
try:
localizer = request.localizer
except Exception:
log.exception('Failed to get localizer')
# NOTE(marcink): Handle bug in pyramid by malformed GET params could crash
# this resulting on various odd errors on missing translators
# see: https://github.com/Pylons/pyramid/issues/3399
def dummy_translate(*args, **kwargs):
return ''.join(args)
request.translate = tsf
request.plularize = dummy_translate
raise HTTPBadRequest()
localizer = request.localizer
def auto_translate(*args, **kwargs):
return localizer.translate(tsf(*args, **kwargs))