From bf315d06fed11f864589e6efe3f50b8da9e14b66 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Sat, 27 Mar 2021 11:20:01 -0500 Subject: [PATCH] Grab the much more-pythonic CF email decode from #37 --- sites/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sites/__init__.py b/sites/__init__.py index 252afc8..e365c68 100644 --- a/sites/__init__.py +++ b/sites/__init__.py @@ -201,9 +201,8 @@ class Site: # [email protected]_The_Sky for a in contents.find_all('a', class_='__cf_email__', href='/cdn-cgi/l/email-protection'): # See: https://usamaejaz.com/cloudflare-email-decoding/ - encoded = a['data-cfemail'] - r = int(encoded[:2], 16) - email = ''.join([chr(int(encoded[i:i+2], 16) ^ r) for i in range(2, len(encoded), 2)]) + enc = bytes.fromhex(a['data-cfemail']) + email = bytes([c ^ enc[0] for c in enc[1:]]).decode('utf8') a.insert_before(email) a.decompose() return contents