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:
Klaus-Uwe Mitterer 2017-10-26 22:55:09 +02:00
parent 87f77a769a
commit 316eb271ef
2 changed files with 3 additions and 3 deletions

View file

@ -118,9 +118,9 @@ def application(env, re):
elif rtype.lower() in ["val", "validate"]:
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:
name = cfrm or args["from"][0]
name = cfrm or args["name"][0]
if not name:
raise ValueError()

View file

@ -4,7 +4,7 @@ import urllib.parse
from classes import *
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):
stations = json.loads(getValidator(name))