forked from indymedia/epicyon
Consistent utf string
parent
f5df29cda9
commit
8ad7ee5ff2
4
auth.py
4
auth.py
|
@ -36,7 +36,7 @@ def createBasicAuthHeader(nickname: str,password: str) -> str:
|
||||||
"""This is only used by tests
|
"""This is only used by tests
|
||||||
"""
|
"""
|
||||||
authStr=nickname.replace('\n','')+':'+password.replace('\n','')
|
authStr=nickname.replace('\n','')+':'+password.replace('\n','')
|
||||||
return 'Basic '+base64.b64encode(authStr.encode('utf8')).decode('utf8')
|
return 'Basic '+base64.b64encode(authStr.encode('utf-8')).decode('utf-8')
|
||||||
|
|
||||||
def authorizeBasic(baseDir: str,authHeader: str) -> bool:
|
def authorizeBasic(baseDir: str,authHeader: str) -> bool:
|
||||||
"""HTTP basic auth
|
"""HTTP basic auth
|
||||||
|
@ -44,7 +44,7 @@ def authorizeBasic(baseDir: str,authHeader: str) -> bool:
|
||||||
if ' ' not in authHeader:
|
if ' ' not in authHeader:
|
||||||
return False
|
return False
|
||||||
base64Str = authHeader.split(' ')[1].replace('\n','')
|
base64Str = authHeader.split(' ')[1].replace('\n','')
|
||||||
plain = base64.b64decode(base64Str).decode('utf8')
|
plain = base64.b64decode(base64Str).decode('utf-8')
|
||||||
if ':' not in plain:
|
if ':' not in plain:
|
||||||
return False
|
return False
|
||||||
nickname = plain.split(':')[0]
|
nickname = plain.split(':')[0]
|
||||||
|
|
|
@ -177,10 +177,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
filename=self.server.baseDir+self.path
|
filename=self.server.baseDir+self.path
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
self._set_headers('application/json')
|
self._set_headers('application/json')
|
||||||
with open(filename, 'r', encoding='utf8') as File:
|
with open(filename, 'r', encoding='utf-8') as File:
|
||||||
content = File.read()
|
content = File.read()
|
||||||
contentJson=json.loads(content)
|
contentJson=json.loads(content)
|
||||||
self.wfile.write(json.dumps(contentJson).encode('utf8'))
|
self.wfile.write(json.dumps(contentJson).encode('utf-8'))
|
||||||
else:
|
else:
|
||||||
if self.server.debug:
|
if self.server.debug:
|
||||||
print('DEBUG: GET Unknown file')
|
print('DEBUG: GET Unknown file')
|
||||||
|
|
Loading…
Reference in New Issue