Skip to content

Commit

Permalink
Fix issue zorkian#36 if request URL contains object id that has space…
Browse files Browse the repository at this point in the history
…, api server will crash
  • Loading branch information
maxbear committed Jan 29, 2015
1 parent a7fbebc commit e2e672c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion nagios-api
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import sys
import time
import types
import atexit
import urllib
from gzip import GzipFile
from StringIO import StringIO
from optparse import OptionParser
Expand All @@ -37,7 +38,7 @@ from signal import signal, SIGTERM
CMDFILE = None
CMD_ENABLED = False
LOG_ENABLED = False
URL_REGEX = re.compile(r'^/(\w+)(?:/([\w\d\.\-]+)?)?$')
URL_REGEX = re.compile(r'^/(\w+)(?:/([\w\d\.\-\s]+)?)?$')
NAGIOS = None
NLOG = []
NLOGLINES = 0
Expand Down Expand Up @@ -718,6 +719,7 @@ def http_handler(req):
# All requests should follow this very simple format.
global URL_REGEX
url = req.script_root + req.path
url = urllib.unquote(url).decode('utf8')
res = URL_REGEX.match(url)
if res is None:
return json_error(req, 'Invalid request URI')
Expand Down

0 comments on commit e2e672c

Please sign in to comment.