diff options
| author | Дилян Палаузов <dilyanpalauzov@users.noreply.github.com> | 2017-11-13 16:15:49 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-11-14 10:52:52 -0500 |
| commit | 23bf4ad87f86f44a5ecf9aea722ced76fe7b7fdf (patch) | |
| tree | b6951dcd0887643851803becb4ec608eeab6ba68 /django/middleware | |
| parent | a2ec1e6b2d05a1de86a6d02d1e035250b9fefa77 (diff) | |
Fixed #28795 -- Removed 'not in' checks and used dict.setdefault().
Diffstat (limited to 'django/middleware')
| -rw-r--r-- | django/middleware/locale.py | 3 | ||||
| -rw-r--r-- | django/middleware/security.py | 8 |
2 files changed, 5 insertions, 6 deletions
diff --git a/django/middleware/locale.py b/django/middleware/locale.py index ee057786ee..2399debf6e 100644 --- a/django/middleware/locale.py +++ b/django/middleware/locale.py @@ -57,6 +57,5 @@ class LocaleMiddleware(MiddlewareMixin): if not (i18n_patterns_used and language_from_path): patch_vary_headers(response, ('Accept-Language',)) - if 'Content-Language' not in response: - response['Content-Language'] = language + response.setdefault('Content-Language', language) return response diff --git a/django/middleware/security.py b/django/middleware/security.py index 7bcb72738e..296567432f 100644 --- a/django/middleware/security.py +++ b/django/middleware/security.py @@ -37,10 +37,10 @@ class SecurityMiddleware(MiddlewareMixin): sts_header = sts_header + "; preload" response["strict-transport-security"] = sts_header - if self.content_type_nosniff and 'x-content-type-options' not in response: - response["x-content-type-options"] = "nosniff" + if self.content_type_nosniff: + response.setdefault('x-content-type-options', 'nosniff') - if self.xss_filter and 'x-xss-protection' not in response: - response["x-xss-protection"] = "1; mode=block" + if self.xss_filter: + response.setdefault('x-xss-protection', '1; mode=block') return response |
