Skip to content

Commit

Permalink
MAINT: Fix mumble-build-number.py script
Browse files Browse the repository at this point in the history
Previously the script would assemble the query URL by taking the
individual parameters literally. However, for certain inputs this could
lead to an invalid URL, resulting in an error 400 (Bad Request) when
attempting to make this query to the server.

In order to avoid these situations, the parameters are now properly
encoded (quoted) before being inserted into the query URL. Thus, we
ensure to always produce valid URLs.
  • Loading branch information
Krzmbrzl committed Aug 14, 2022
1 parent 044dede commit d6261d5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/mumble-build-number.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,22 @@

import argparse
import urllib.request
import urllib.parse
import sys

def fetch_build_number(commit = None, version = None, password = None):
if commit is None or version is None:
return None

query = "https://mumble.info/get-build-number?commit=" + commit + "&version=" + version
parameter = {
"commit": commit,
"version": version
}

if not password is None:
query += "&token=" + password
parameter["token"] = password

query = "https://mumble.info/get-build-number?" + urllib.parse.urlencode(parameter)

try:
request = urllib.request.urlopen(query)
Expand Down

0 comments on commit d6261d5

Please sign in to comment.