diff --git a/README.md b/README.md index 5934274..3a14c95 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,10 @@ The log can be viewed via journalctl (or syslog): * Added a shutdown event for custom background workers. * `Request.query` is None if there is no query string present. Previously, the query string was an empty string in this case. This allows making a distinction between empty and absent query strings.  +v0.3.1: + +* CGI: Fixed handling of a missing query string. + ### v0.2  * Added `[cgi] bin_root` configuration option for automatically and dynamically mapping all executables in a directory tree to URL entry points. diff --git a/gmcapsule/__init__.py b/gmcapsule/__init__.py index 6dd0cb3..4179daa 100644 --- a/gmcapsule/__init__.py +++ b/gmcapsule/__init__.py @@ -440,7 +440,7 @@ from .gemini import Server, Cache from .markdown import to_gemtext as markdown_to_gemtext   -__version__ = '0.3.0' +__version__ = '0.3.1' __all__ = [ 'Config', 'Capsule', 'Cache', 'get_mime_type', 'markdown_to_gemtext' diff --git a/gmcapsule/modules/90_cgi.py b/gmcapsule/modules/90_cgi.py index 51d73a2..a533163 100644 --- a/gmcapsule/modules/90_cgi.py +++ b/gmcapsule/modules/90_cgi.py @@ -23,13 +23,13 @@ class CgiContext:  def __call__(self, req): try: - query = urllib.parse.unquote(req.query) env_vars = dict(os.environ)  # Standard CGI variables. env_vars['GATEWAY_INTERFACE'] = 'CGI/1.1' env_vars['REMOTE_ADDR'] = '%s:%d' % req.remote_address - env_vars['QUERY_STRING'] = req.query + if req.query != None: + env_vars['QUERY_STRING'] = req.query env_vars['PATH_INFO'] = req.path env_vars['SCRIPT_NAME'] = self.base_path env_vars['SERVER_SOFTWARE'] = 'GmCapsule/' + gmcapsule.__version__ @@ -37,7 +37,7 @@ class CgiContext: env_vars['SERVER_NAME'] = req.hostname env_vars['SERVER_PORT'] = str(Capsule.config().port()) env_vars[req.scheme.upper() + '_URL'] = f"{req.scheme}://{req.hostname}{req.path}" + ( - '?' + req.query if len(req.query) else '') + '?' + req.query if req.query != None else '') env_vars[req.scheme.upper() + '_URL_PATH'] = req.path  # TLS client certificate.