diff --git a/main.py b/main.py index ea471b2..ffcd71e 100644 --- a/main.py +++ b/main.py @@ -17,9 +17,9 @@ HTTP400 = "400 Bad Request" HTTP405 = "405 Method Not Allowed" HTTP500 = "500 Internal Server Error" -HTML = "text/html" -JSON = "application/json" -XML = "text/xml" +HTML = "text/html; charset=UTF-8" +JSON = "application/json; charset=UTF-8" +XML = "text/xml; charset=UTF-8" DOCSTR = ' Check out the documentation for usage instructions.' @@ -27,6 +27,7 @@ def doConn(req): try: getfrm = req.cfrm if "cfrm" in dir(req) and req.cfrm else req.args["from"][0] if "from" in req.args else None getto = req.cto if "cto" in dir(req) and req.cto else req.args["to"][0] if "to" in req.args else None + try: frm = html.unescape(getfrm.encode("latin-1").decode("utf-8")) to = html.unescape(getto.encode("latin-1").decode("utf-8")) @@ -37,6 +38,7 @@ def doConn(req): if not frm or not to: raise ValueError() + except Exception: content = "

400 Bad Request

\n" content += "\"from\"and \"to\" values are required for this type of request." diff --git a/workers/val.py b/workers/val.py index f0112c9..632a22f 100644 --- a/workers/val.py +++ b/workers/val.py @@ -3,7 +3,7 @@ import urllib.parse from classes import * def getValidator(name): - data = HTTPClient().get("http://scotty.oebb.at/bin/ajax-getstop.exe/dn?REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S=%s?&js=true&" % urllib.parse.quote(name)).text + data = HTTPClient().get("http://scotty.oebb.at/bin/ajax-getstop.exe/dn?REQ0JourneyStopsS0A=255&REQ0JourneyStopsB=12&S='%s'?&js=true&" % urllib.parse.quote(name.encode("latin-1"))).text return "=".join(data.split("=")[1:]).split(";")[0] def validateName(name):