From c4977b80ebf062ca394b9b3bf4d8a23297a26775 Mon Sep 17 00:00:00 2001 From: Alex Fabijanic Date: Wed, 20 Mar 2024 12:32:48 -0500 Subject: [PATCH] fix(URI): don't lowercase host part if it's a Unix domain socket #4468 --- Foundation/src/URI.cpp | 3 ++- Foundation/testsuite/src/URITest.cpp | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Foundation/src/URI.cpp b/Foundation/src/URI.cpp index e64629fb21..bc7582b489 100644 --- a/Foundation/src/URI.cpp +++ b/Foundation/src/URI.cpp @@ -857,7 +857,8 @@ void URI::parseHostAndPort(std::string::const_iterator& it, const std::string::c } else _port = 0; _host = host; - toLowerInPlace(_host); + if (_host.size() && _host[0] != '%') + toLowerInPlace(_host); } diff --git a/Foundation/testsuite/src/URITest.cpp b/Foundation/testsuite/src/URITest.cpp index e835b377b7..4008bdbeee 100644 --- a/Foundation/testsuite/src/URITest.cpp +++ b/Foundation/testsuite/src/URITest.cpp @@ -798,6 +798,15 @@ void URITest::testOther() assertTrue (uri.getRawFragment() == "foo%2Fbar"); assertTrue (uri.toString() == "http://google.com/search?q=hello+world#foo%2Fbar"); assertTrue (uri.getPathEtc() == "/search?q=hello+world#foo%2Fbar"); + + uri = "http://ServerSocket.com/index.html"; + assertTrue (uri.toString() == "http://serversocket.com/index.html"); + + uri = "http+unix://%2Ftmp%2FServerSocket/index.html"; + assertTrue (uri.toString() == "http+unix://%2Ftmp%2FServerSocket/index.html"); + std::string decoded; + uri.decode("http+unix://%2Ftmp%2FServerSocket/index.html", decoded); + assertTrue (decoded == "http+unix:///tmp/ServerSocket/index.html"); }