mirror of https://github.com/scrapy/scrapy.git
Fix tests
This commit is contained in:
parent
ebcacd3f54
commit
b6c761d2b4
|
|
@ -159,7 +159,8 @@ class StrictOriginPolicy(ReferrerPolicy):
|
|||
name = POLICY_STRICT_ORIGIN
|
||||
|
||||
def referrer(self, response, request):
|
||||
if ((self.tls_protected(response) and self.potentially_trustworthy(request))
|
||||
if ((self.tls_protected(response) and
|
||||
self.potentially_trustworthy(request))
|
||||
or not self.tls_protected(response)):
|
||||
return self.origin_referrer(response)
|
||||
|
||||
|
|
@ -208,9 +209,9 @@ class StrictOriginWhenCrossOriginPolicy(ReferrerPolicy):
|
|||
origin = self.origin(response)
|
||||
if origin == self.origin(request):
|
||||
return self.stripped_referrer(response)
|
||||
elif ((urlparse_cached(response).scheme in ('https', 'ftps') and
|
||||
elif ((self.tls_protected(response) and
|
||||
self.potentially_trustworthy(request))
|
||||
or urlparse_cached(response).scheme == 'http'):
|
||||
or not self.tls_protected(response)):
|
||||
return self.origin_referrer(response)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -232,7 +232,13 @@ class MixinStrictOriginWhenCrossOrigin(object):
|
|||
# downgrade
|
||||
('https://example4.com/page.html', 'http://example4.com/not-page.html', None),
|
||||
('https://example4.com/page.html', 'http://not.example4.com/', None),
|
||||
('ftp://example4.com/urls.zip', 'http://example4.com/not-page.html', None),
|
||||
|
||||
# non-TLS to non-TLS
|
||||
('ftp://example4.com/urls.zip', 'http://example4.com/not-page.html', b'ftp://example4.com/'),
|
||||
|
||||
# upgrade
|
||||
('http://example4.com/page.html', 'https://example4.com/not-page.html', b'http://example4.com/'),
|
||||
('http://example4.com/page.html', 'https://not.example4.com/', b'http://example4.com/'),
|
||||
|
||||
# Different protocols: send origin as referrer
|
||||
('ftps://example4.com/urls.zip', 'https://example4.com/not-page.html', b'ftps://example4.com/'),
|
||||
|
|
|
|||
Loading…
Reference in New Issue