mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
userAgents: avoid potential IndexError
random.choice() should only be run after verifying the config has been set.
This commit is contained in:
parent
4c4d0024ca
commit
5315cd3275
@ -1331,8 +1331,8 @@ def defaultHttpHeaders(network, channel):
|
||||
try:
|
||||
language = supybot.protocols.http.requestLanguage.getSpecific(
|
||||
network, channel)()
|
||||
agent = random.choice(supybot.protocols.http.userAgents.getSpecific(
|
||||
network, channel)())
|
||||
agent = supybot.protocols.http.userAgents.getSpecific(
|
||||
network, channel)()
|
||||
except registry.NonExistentRegistryEntry:
|
||||
pass # Starting up; headers will be set by HttpRequestLanguage/UserAgents later
|
||||
else:
|
||||
@ -1340,7 +1340,9 @@ def defaultHttpHeaders(network, channel):
|
||||
headers['Accept-Language'] = language
|
||||
elif 'Accept-Language' in headers:
|
||||
del headers['Accept-Language']
|
||||
if agent.strip():
|
||||
if agent:
|
||||
agent = random.choice(agent).strip()
|
||||
if agent:
|
||||
headers['User-agent'] = agent
|
||||
return headers
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user