Apply patch from nervuri:matrix.org to address index bug and url parse fix
authorNeil <neil@mckillop.org>
Sun, 17 Jan 2021 21:39:53 +0000 (21:39 +0000)
committerNeil <neil@mckillop.org>
Sun, 17 Jan 2021 21:39:53 +0000 (21:39 +0000)
gemini.class.php

index fe8b5fb509eb253f90f0f5cd8bf5c17e710a3d10..576d9aaf39b3fbf0e6dc6c8e3cafdb6d2ec6aacc 100644 (file)
@@ -40,8 +40,8 @@ class Gemini {
        }
 
        function parse_request($request) {
-               $data = parse_url($request);
-               return $data;
+               $url = trim($request); // strip <CR><LF> from the end
+               return parse_url($url);
        }
 
        function get_valid_hosts() {
@@ -93,10 +93,10 @@ class Gemini {
                // wtf am I missing?
                $url['path'] = str_replace("__", "", $url['path']);
                // force an index file to be appended if a filename is missing
-               if(substr($url['path'], -1) == "/") {
-                       $url['path'] .= $this->default_index_file;
-               } elseif($url['path'] == "/" or $url['path'] == "") {
+               if(empty($url['path'])) {
                        $url['path'] = "/".$this->default_index_file;
+               } elseif(substr($url['path'], -1) == "/") {
+                       $url['path'] .= $this->default_index_file;
                }
 
                return $this->data_dir.$hostname.$url['path'];