Error handler for ascii encoding

main
Bob Mottram 2023-01-18 10:18:48 +00:00
parent 9320f5bb76
commit 413b60c9e3
2 changed files with 9 additions and 3 deletions

View File

@ -18715,8 +18715,8 @@ class PubServer(BaseHTTPRequestHandler):
hashtag_url = self.path.split('?remotetag=')[1]
if ';' in hashtag_url:
hashtag_url = hashtag_url.split(';')[0]
hashtag_url = \
urllib.parse.unquote_plus(hashtag_url.replace('--', '/'))
hashtag_url = hashtag_url.replace('--', '/')
hashtag_url = urllib.parse.unquote_plus(hashtag_url)
page_number = 1
if ';page=' in self.path:

View File

@ -117,7 +117,13 @@ def sign_post_headers(date_str: str, private_key_pem: str,
# strip the trailing linefeed
signed_header_text = signed_header_text.rstrip('\n')
# signed_header_text.encode('ascii') matches
header_digest = get_sha_256(signed_header_text.encode('ascii'))
try:
sig_header_encoded = signed_header_text.encode('ascii')
except UnicodeEncodeError:
sig_header_encoded = signed_header_text
print('WARN: sign_post_headers unable to ascii encode ' +
signed_header_text)
header_digest = get_sha_256(sig_header_encoded)
# print('header_digest2: ' + str(header_digest))
# Sign the digest