diff --git a/daemon.py b/daemon.py index c15d16bed..046805c97 100644 --- a/daemon.py +++ b/daemon.py @@ -268,7 +268,7 @@ from utils import getOccupationName from utils import setOccupationName from utils import loadTranslationsFromFile from utils import getLocalNetworkAddresses -from utils import decodedHost +from utils import decoded_host from utils import isPublicPost from utils import get_locked_account from utils import has_users_path @@ -13312,7 +13312,7 @@ class PubServer(BaseHTTPRequestHandler): callingDomain = self.server.domain_full if self.headers.get('Host'): - callingDomain = decodedHost(self.headers['Host']) + callingDomain = decoded_host(self.headers['Host']) if self.server.onion_domain: if callingDomain != self.server.domain and \ callingDomain != self.server.domain_full and \ @@ -16369,7 +16369,7 @@ class PubServer(BaseHTTPRequestHandler): def do_HEAD(self): callingDomain = self.server.domain_full if self.headers.get('Host'): - callingDomain = decodedHost(self.headers['Host']) + callingDomain = decoded_host(self.headers['Host']) if self.server.onion_domain: if callingDomain != self.server.domain and \ callingDomain != self.server.domain_full and \ @@ -17483,7 +17483,7 @@ class PubServer(BaseHTTPRequestHandler): callingDomain = self.server.domain_full if self.headers.get('Host'): - callingDomain = decodedHost(self.headers['Host']) + callingDomain = decoded_host(self.headers['Host']) if self.server.onion_domain: if callingDomain != self.server.domain and \ callingDomain != self.server.domain_full and \ diff --git a/tests.py b/tests.py index da7733bb4..c6b1db478 100644 --- a/tests.py +++ b/tests.py @@ -68,7 +68,7 @@ from utils import dateSecondsToString from utils import validPassword from utils import userAgentDomain from utils import camelCaseSplit -from utils import decodedHost +from utils import decoded_host from utils import getFullDomain from utils import validNickname from utils import firstParagraphFromString @@ -4865,13 +4865,13 @@ def _testMastoApi(): def _testDomainHandling(): print('testDomainHandling') testDomain = 'localhost' - assert decodedHost(testDomain) == testDomain + assert decoded_host(testDomain) == testDomain testDomain = '127.0.0.1:60' - assert decodedHost(testDomain) == testDomain + assert decoded_host(testDomain) == testDomain testDomain = '192.168.5.153' - assert decodedHost(testDomain) == testDomain + assert decoded_host(testDomain) == testDomain testDomain = 'xn--espaa-rta.icom.museum' - assert decodedHost(testDomain) == "españa.icom.museum" + assert decoded_host(testDomain) == "españa.icom.museum" def _testPrepareHtmlPostNickname(): diff --git a/utils.py b/utils.py index 9910bb308..0de196e19 100644 --- a/utils.py +++ b/utils.py @@ -168,7 +168,7 @@ def _local_network_host(host: str) -> bool: return False -def decodedHost(host: str) -> str: +def decoded_host(host: str) -> str: """Convert hostname to internationalized domain https://en.wikipedia.org/wiki/Internationalized_domain_name """