How did nobody ever notice that the validator wasn't working? Also, escaping values before passing them to the HAFAS station endpoint.
This commit is contained in:
parent
87f77a769a
commit
316eb271ef
4
main.py
4
main.py
|
@ -118,9 +118,9 @@ def application(env, re):
|
||||||
elif rtype.lower() in ["val", "validate"]:
|
elif rtype.lower() in ["val", "validate"]:
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
name = (cfrm or args["from"][0]).encode("latin-1").decode("utf-8")
|
name = (cfrm or args["name"][0]).encode("latin-1").decode("utf-8")
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
name = cfrm or args["from"][0]
|
name = cfrm or args["name"][0]
|
||||||
|
|
||||||
if not name:
|
if not name:
|
||||||
raise ValueError()
|
raise ValueError()
|
||||||
|
|
|
@ -4,7 +4,7 @@ import urllib.parse
|
||||||
from classes import *
|
from classes import *
|
||||||
|
|
||||||
def getValidator(name):
|
def getValidator(name):
|
||||||
return requests.get("http://www.oebb.at/__ressources/system/stationsHafas.jsp?q=%s" % name).text
|
return requests.get("http://www.oebb.at/__ressources/system/stationsHafas.jsp?q=%s" % urllib.parse.quote(name)).text
|
||||||
|
|
||||||
def validateName(name):
|
def validateName(name):
|
||||||
stations = json.loads(getValidator(name))
|
stations = json.loads(getValidator(name))
|
||||||
|
|
Loading…
Reference in a new issue