[PATCH 3/5] kernelbase: Allow ports to contain any characters in UrlGetPart().

Zebediah Figura zfigura at codeweavers.com
Mon Feb 14 20:37:08 CST 2022


Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/kernelbase/path.c   | 16 +++-------------
 dlls/shlwapi/tests/url.c |  6 +++---
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/dlls/kernelbase/path.c b/dlls/kernelbase/path.c
index 954faf47a99..dfb37006da8 100644
--- a/dlls/kernelbase/path.c
+++ b/dlls/kernelbase/path.c
@@ -77,7 +77,6 @@ struct parsed_url
 enum url_scan_type
 {
     SCHEME,
-    PORT,
     USERPASS,
 };
 
@@ -4212,14 +4211,6 @@ static const WCHAR * scan_url(const WCHAR *start, DWORD *size, enum url_scan_typ
         }
         break;
 
-    case PORT:
-        while (*start >= '0' && *start <= '9')
-        {
-            start++;
-            (*size)++;
-        }
-        break;
-
     default:
         FIXME("unknown type %d\n", type);
         return L"";
@@ -4286,10 +4277,9 @@ static LONG parse_url(const WCHAR *url, struct parsed_url *pl)
 
     if (*work == ':')
     {
-        /* parse port */
-        work++;
-        pl->port = work;
-        work = scan_url(pl->port, &pl->port_len, PORT);
+        pl->port = work + 1;
+        work = parse_url_element( pl->port, L"/\\?#" );
+        pl->port_len = work - pl->port;
     }
     if (*work == '/')
     {
diff --git a/dlls/shlwapi/tests/url.c b/dlls/shlwapi/tests/url.c
index 07d3ebfa331..c4afb1375e9 100644
--- a/dlls/shlwapi/tests/url.c
+++ b/dlls/shlwapi/tests/url.c
@@ -630,7 +630,7 @@ static void test_UrlGetPart(void)
         {"http://localhost:port/", URL_PART_USERNAME, 0, E_INVALIDARG, .todo_hr = TRUE},
         {"http://localhost:port/", URL_PART_PASSWORD, 0, E_INVALIDARG, .todo_hr = TRUE},
         {"http://localhost:port/", URL_PART_HOSTNAME, 0, S_OK, "localhost"},
-        {"http://localhost:port/", URL_PART_PORT, 0, S_OK, "port", .todo_hr = TRUE},
+        {"http://localhost:port/", URL_PART_PORT, 0, S_OK, "port"},
         {"http://:", URL_PART_HOSTNAME, 0, S_FALSE, ""},
         {"http://:", URL_PART_PORT, 0, S_FALSE, ""},
 
@@ -651,7 +651,7 @@ static void test_UrlGetPart(void)
         {"http://:@", URL_PART_HOSTNAME, 0, S_FALSE, ""},
 
         {"http://host:port:q", URL_PART_HOSTNAME, 0, S_OK, "host"},
-        {"http://host:port:q", URL_PART_PORT, 0, S_OK, "port:q", .todo_hr = TRUE},
+        {"http://host:port:q", URL_PART_PORT, 0, S_OK, "port:q"},
         {"http://user:pass:q@host", URL_PART_USERNAME, 0, S_OK, "user", .todo_hr = TRUE},
         {"http://user:pass:q@host", URL_PART_PASSWORD, 0, S_OK, "pass:q", .todo_hr = TRUE},
         {"http://user@host@q", URL_PART_USERNAME, 0, S_OK, "user"},
@@ -678,7 +678,7 @@ static void test_UrlGetPart(void)
         {"http:// !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff:pass at host", URL_PART_USERNAME, 0, S_OK, " !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", .todo_hr = TRUE},
         {"http://user: !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff at host", URL_PART_PASSWORD, 0, S_OK, " !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", .todo_hr = TRUE},
         {"http:// !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", URL_PART_HOSTNAME, 0, S_OK, " !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", .todo_hr = TRUE},
-        {"http://host: !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", URL_PART_PORT, 0, S_OK, " !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", .todo_hr = TRUE},
+        {"http://host: !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff", URL_PART_PORT, 0, S_OK, " !\"$%&'()*+,-.;<=>[]^_`{|~}\x01\x7f\xff"},
 
         {"http:///index.html", URL_PART_HOSTNAME, 0, S_FALSE, ""},
         {"http:///index.html", URL_PART_HOSTNAME, URL_PARTFLAG_KEEPSCHEME, S_OK, "http:", .todo_hr = TRUE},
-- 
2.34.1




More information about the wine-devel mailing list