kopia lustrzana https://github.com/snarfed/bridgy-fed
Web.get_or_create: bug fix for normalizing domain case
fixes https://console.cloud.google.com/errors/detail/CKOs59zx0rSXQg;time=P30D?project=bridgy-federatedpull/905/head
rodzic
ed366f8426
commit
42b4541c8d
|
@ -537,6 +537,11 @@ class WebTest(TestCase):
|
||||||
self.user.put()
|
self.user.put()
|
||||||
self.assertIsNone(Web.get_or_create('user.com'))
|
self.assertIsNone(Web.get_or_create('user.com'))
|
||||||
|
|
||||||
|
def test_get_or_create_existing_opted_out_normalize_case(self, *_):
|
||||||
|
self.user.manual_opt_out = True
|
||||||
|
self.user.put()
|
||||||
|
self.assertIsNone(Web.get_or_create('uSeR.cOm'))
|
||||||
|
|
||||||
def test_bad_source_url(self, *mocks):
|
def test_bad_source_url(self, *mocks):
|
||||||
orig_count = Object.query().count()
|
orig_count = Object.query().count()
|
||||||
|
|
||||||
|
@ -2473,7 +2478,7 @@ class WebUtilTest(TestCase):
|
||||||
self.user = self.make_user('user.com', cls=Web)
|
self.user = self.make_user('user.com', cls=Web)
|
||||||
|
|
||||||
def test_key_for(self, *_):
|
def test_key_for(self, *_):
|
||||||
for id in 'user.com', 'http://user.com', 'https://user.com/':
|
for id in 'user.com', 'http://user.com', 'https://user.com/', 'uSeR.cOm':
|
||||||
self.assertEqual(Web(id='user.com').key, Web.key_for(id))
|
self.assertEqual(Web(id='user.com').key, Web.key_for(id))
|
||||||
|
|
||||||
for bad in '', 'foo', 'https://foo/', 'foo bar', 'user.json':
|
for bad in '', 'foo', 'https://foo/', 'foo bar', 'user.json':
|
||||||
|
|
3
web.py
3
web.py
|
@ -140,7 +140,7 @@ class Web(User, Protocol):
|
||||||
if not key:
|
if not key:
|
||||||
return None # opted out
|
return None # opted out
|
||||||
|
|
||||||
domain = key.id().lower().strip('.')
|
domain = key.id()
|
||||||
user = super().get_or_create(domain, **kwargs)
|
user = super().get_or_create(domain, **kwargs)
|
||||||
|
|
||||||
if not user.existing:
|
if not user.existing:
|
||||||
|
@ -307,6 +307,7 @@ class Web(User, Protocol):
|
||||||
if not id:
|
if not id:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
id = id.lower().strip('.')
|
||||||
if util.is_web(id):
|
if util.is_web(id):
|
||||||
parsed = urlparse(id)
|
parsed = urlparse(id)
|
||||||
if parsed.path in ('', '/'):
|
if parsed.path in ('', '/'):
|
||||||
|
|
Ładowanie…
Reference in New Issue