fix edge cases with @
[m6w6/ext-http] / php_http_url.c
index 4263aab6a068d7e961243a8608e751c3c4a7df1c..1f06271f9527183f12c9c5c2a46506b14a674b74 100644 (file)
@@ -528,7 +528,7 @@ static STATUS parse_hostinfo(php_http_url_t *url, const char *ptr)
                case ':':
                        if (port) {
                                php_error_docref(NULL TSRMLS_CC, E_WARNING,
-                                               "Failed to parse port; duplicate ':' at pos %u in '%s'",
+                                               "Failed to parse port; unexpected ':' at pos %u in '%s'",
                                                (unsigned) (ptr - tmp), tmp);
                                return FAILURE;
                        }
@@ -625,12 +625,19 @@ static STATUS parse_hostinfo(php_http_url_t *url, const char *ptr)
 
 static const char *parse_authority(php_http_url_t *url)
 {
-       const char *tmp = url->ptr;
+       const char *tmp = url->ptr, *host = NULL;
 
        do {
                switch (*url->ptr) {
                case '@':
                        /* userinfo delimiter */
+                       if (host) {
+                               TSRMLS_FETCH_FROM_CTX(url->ts);
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING,
+                                               "Failed to parse userinfo; unexpected '@'");
+                               return NULL;
+                       }
+                       host = url->ptr + 1;
                        if (tmp != url->ptr && SUCCESS != parse_userinfo(url, tmp)) {
                                return NULL;
                        }