mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-23 19:36:56 -08:00
encode params correctly when doing webfinger
This commit is contained in:
parent
79307ad5c0
commit
8ce71bdd54
1 changed files with 6 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import random
|
import random
|
||||||
|
import urllib
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from datetime import datetime, timedelta, date
|
from datetime import datetime, timedelta, date
|
||||||
from typing import List, Literal, Union
|
from typing import List, Literal, Union
|
||||||
|
@ -71,8 +72,12 @@ def get_request(uri, params=None, headers=None) -> requests.Response:
|
||||||
headers = {'User-Agent': 'PieFed/1.0'}
|
headers = {'User-Agent': 'PieFed/1.0'}
|
||||||
else:
|
else:
|
||||||
headers.update({'User-Agent': 'PieFed/1.0'})
|
headers.update({'User-Agent': 'PieFed/1.0'})
|
||||||
|
if params and '/webfinger' in uri:
|
||||||
|
payload_str = urllib.parse.urlencode(params, safe=':@')
|
||||||
|
else:
|
||||||
|
payload_str = urllib.parse.urlencode(params) if params else None
|
||||||
try:
|
try:
|
||||||
response = requests.get(uri, params=params, headers=headers, timeout=5, allow_redirects=True)
|
response = requests.get(uri, params=payload_str, headers=headers, timeout=5, allow_redirects=True)
|
||||||
except requests.exceptions.SSLError as invalid_cert:
|
except requests.exceptions.SSLError as invalid_cert:
|
||||||
# Not our problem if the other end doesn't have proper SSL
|
# Not our problem if the other end doesn't have proper SSL
|
||||||
current_app.logger.info(f"{uri} {invalid_cert}")
|
current_app.logger.info(f"{uri} {invalid_cert}")
|
||||||
|
|
Loading…
Reference in a new issue