net.dns: Make sure argument to math.randomseed does not overflow a 32 bit unsigned...
[prosody.git] / net / http / parser.lua
index c760a0a44453850a202c962a434fe15bae715d9e..2545b5ac41457b88e345f5a6743650052e43ff40 100644 (file)
@@ -77,6 +77,7 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb)
                                                        end
                                                end
                                        end
+                                       if not first_line then error = true; return error_cb("invalid-status-line"); end
                                        len = tonumber(headers["content-length"]); -- TODO check for invalid len
                                        if client then
                                                -- FIXME handle '100 Continue' response (by skipping it)
@@ -91,7 +92,15 @@ function httpstream.new(success_cb, error_cb, parser_type, options_cb)
                                                        responseheaders = headers;
                                                };
                                        else
-                                               local parsed_url = url_parse(path);
+                                               local parsed_url;
+                                               if path:byte() == 47 then -- starts with /
+                                                       local _path, _query = path:match("([^?]*).?(.*)");
+                                                       if _query == "" then _query = nil; end
+                                                       parsed_url = { path = _path, query = _query };
+                                               else
+                                                       parsed_url = url_parse(path);
+                                                       if not(parsed_url and parsed_url.path) then error = true; return error_cb("invalid-url"); end
+                                               end
                                                path = preprocess_path(parsed_url.path);
                                                headers.host = parsed_url.host or headers.host;