summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRye Mutt <rye@alchemyviewer.org>2024-07-28 16:27:42 -0400
committerAndrey Kleshchev <117672381+akleshchev@users.noreply.github.com>2024-07-29 13:33:12 +0300
commit3e322df4fb71cbeff27aab85bb48c7da595b548c (patch)
tree6b5a975903f9ae3f26073b3de110ccdb9c4c991a /indra
parent1c50229e6e8ceff6ebddff72aa26f39eed3a561c (diff)
Replace liburiparser with boost::url
Diffstat (limited to 'indra')
-rw-r--r--indra/cmake/Boost.cmake9
-rw-r--r--indra/cmake/CMakeLists.txt1
-rw-r--r--indra/cmake/Copy3rdPartyLibs.cmake4
-rw-r--r--indra/cmake/URIPARSER.cmake19
-rw-r--r--indra/llcommon/CMakeLists.txt2
-rw-r--r--indra/llcommon/lluriparser.cpp168
-rw-r--r--indra/llcommon/lluriparser.h27
-rw-r--r--indra/llcorehttp/CMakeLists.txt1
-rw-r--r--indra/llui/llurlentry.cpp2
-rw-r--r--indra/llui/llurlregistry.cpp2
-rw-r--r--indra/newview/CMakeLists.txt2
-rw-r--r--indra/newview/llweb.cpp1
-rwxr-xr-xindra/newview/viewer_manifest.py4
13 files changed, 68 insertions, 174 deletions
diff --git a/indra/cmake/Boost.cmake b/indra/cmake/Boost.cmake
index 601a23a86d..8c5b946753 100644
--- a/indra/cmake/Boost.cmake
+++ b/indra/cmake/Boost.cmake
@@ -24,7 +24,8 @@ if (WINDOWS)
libboost_program_options-mt${addrsfx}
libboost_regex-mt${addrsfx}
libboost_system-mt${addrsfx}
- libboost_thread-mt${addrsfx})
+ libboost_thread-mt${addrsfx}
+ libboost_url-mt${addrsfx})
elseif (LINUX)
target_link_libraries( ll::boost INTERFACE
boost_context-mt${addrsfx}
@@ -34,7 +35,8 @@ elseif (LINUX)
boost_regex-mt${addrsfx}
boost_signals-mt${addrsfx}
boost_system-mt${addrsfx}
- boost_thread-mt${addrsfx})
+ boost_thread-mt${addrsfx}
+ boost_url-mt${addrsfx})
elseif (DARWIN)
target_link_libraries( ll::boost INTERFACE
boost_context-mt${addrsfx}
@@ -43,7 +45,8 @@ elseif (DARWIN)
boost_program_options-mt${addrsfx}
boost_regex-mt${addrsfx}
boost_system-mt${addrsfx}
- boost_thread-mt${addrsfx})
+ boost_thread-mt${addrsfx}
+ boost_url-mt${addrsfx})
endif (WINDOWS)
if (LINUX)
diff --git a/indra/cmake/CMakeLists.txt b/indra/cmake/CMakeLists.txt
index c067105f68..73b614e0af 100644
--- a/indra/cmake/CMakeLists.txt
+++ b/indra/cmake/CMakeLists.txt
@@ -57,7 +57,6 @@ set(cmake_SOURCE_FILES
Tut.cmake
UI.cmake
UnixInstall.cmake
- URIPARSER.cmake
Variables.cmake
ViewerMiscLibs.cmake
VisualLeakDetector.cmake
diff --git a/indra/cmake/Copy3rdPartyLibs.cmake b/indra/cmake/Copy3rdPartyLibs.cmake
index 3f43ec6729..c2ba9231cc 100644
--- a/indra/cmake/Copy3rdPartyLibs.cmake
+++ b/indra/cmake/Copy3rdPartyLibs.cmake
@@ -58,7 +58,6 @@ if(WINDOWS)
libaprutil-1.dll
nghttp2.dll
libhunspell.dll
- uriparser.dll
)
# OpenSSL
@@ -190,9 +189,6 @@ elseif(DARWIN)
libndofdev.dylib
libnghttp2.dylib
libnghttp2.14.dylib
- liburiparser.dylib
- liburiparser.1.dylib
- liburiparser.1.0.27.dylib
)
if (TARGET ll::openal)
diff --git a/indra/cmake/URIPARSER.cmake b/indra/cmake/URIPARSER.cmake
deleted file mode 100644
index 6c33ff70e1..0000000000
--- a/indra/cmake/URIPARSER.cmake
+++ /dev/null
@@ -1,19 +0,0 @@
-# -*- cmake -*-
-
-include_guard()
-
-include(Prebuilt)
-
-add_library( ll::uriparser INTERFACE IMPORTED )
-
-use_system_binary( uriparser )
-
-use_prebuilt_binary(uriparser)
-if (WINDOWS)
- target_link_libraries( ll::uriparser INTERFACE uriparser)
-elseif (LINUX)
- target_link_libraries( ll::uriparser INTERFACE uriparser)
-elseif (DARWIN)
- target_link_libraries( ll::uriparser INTERFACE liburiparser.dylib)
-endif (WINDOWS)
-target_include_directories( ll::uriparser SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include/uriparser)
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt
index 95e991c246..8e43627a5f 100644
--- a/indra/llcommon/CMakeLists.txt
+++ b/indra/llcommon/CMakeLists.txt
@@ -10,7 +10,6 @@ include(Boost)
include(LLSharedLibs)
include(Copy3rdPartyLibs)
include(ZLIBNG)
-include(URIPARSER)
include(Tracy)
@@ -278,7 +277,6 @@ target_link_libraries(
ll::expat
ll::zlib-ng
ll::boost
- ll::uriparser
ll::oslibraries
ll::tracy
)
diff --git a/indra/llcommon/lluriparser.cpp b/indra/llcommon/lluriparser.cpp
index 2ebb7fc742..33a48d970d 100644
--- a/indra/llcommon/lluriparser.cpp
+++ b/indra/llcommon/lluriparser.cpp
@@ -29,12 +29,7 @@
#include "linden_common.h"
#include "lluriparser.h"
-#if LL_DARWIN
-#include <signal.h>
-#include <setjmp.h>
-#endif
-
-LLUriParser::LLUriParser(const std::string& u) : mTmpScheme(false), mNormalizedTmp(false), mRes(0)
+LLUriParser::LLUriParser(const std::string& u) : mTmpScheme(false), mNormalizedTmp(false), mRes(false)
{
if (u.find("://") == std::string::npos)
{
@@ -42,36 +37,52 @@ LLUriParser::LLUriParser(const std::string& u) : mTmpScheme(false), mNormalizedT
mTmpScheme = true;
}
- mNormalizedUri += u.c_str();
+ mNormalizedUri.append(u);
mRes = parse();
}
LLUriParser::~LLUriParser()
{
- uriFreeUriMembersA(&mUri);
}
-S32 LLUriParser::parse()
+bool LLUriParser::parse()
{
- mRes = uriParseSingleUriA(&mUri, mNormalizedUri.c_str(), NULL);
+ try
+ {
+ auto res = boost::urls::parse_uri(mNormalizedUri);
+ if (res)
+ {
+ mUri = *res;
+ mRes = true;
+ }
+ else
+ {
+ mRes = false;
+ }
+ }
+ catch (const std::length_error&)
+ {
+ LL_WARNS() << "Failed to parse uri due to exceeding uri_view max_size" << LL_ENDL;
+ mRes = false;
+ }
return mRes;
}
-const char * LLUriParser::scheme() const
+const std::string& LLUriParser::scheme() const
{
- return mScheme.c_str();
+ return mScheme;
}
-void LLUriParser::sheme(const std::string& s)
+void LLUriParser::scheme(const std::string& s)
{
mTmpScheme = !s.size();
mScheme = s;
}
-const char * LLUriParser::port() const
+const std::string& LLUriParser::port() const
{
- return mPort.c_str();
+ return mPort;
}
void LLUriParser::port(const std::string& s)
@@ -79,9 +90,9 @@ void LLUriParser::port(const std::string& s)
mPort = s;
}
-const char * LLUriParser::host() const
+const std::string& LLUriParser::host() const
{
- return mHost.c_str();
+ return mHost;
}
void LLUriParser::host(const std::string& s)
@@ -89,9 +100,9 @@ void LLUriParser::host(const std::string& s)
mHost = s;
}
-const char * LLUriParser::path() const
+const std::string& LLUriParser::path() const
{
- return mPath.c_str();
+ return mPath;
}
void LLUriParser::path(const std::string& s)
@@ -99,9 +110,9 @@ void LLUriParser::path(const std::string& s)
mPath = s;
}
-const char * LLUriParser::query() const
+const std::string& LLUriParser::query() const
{
- return mQuery.c_str();
+ return mQuery;
}
void LLUriParser::query(const std::string& s)
@@ -109,9 +120,9 @@ void LLUriParser::query(const std::string& s)
mQuery = s;
}
-const char * LLUriParser::fragment() const
+const std::string& LLUriParser::fragment() const
{
- return mFragment.c_str();
+ return mFragment;
}
void LLUriParser::fragment(const std::string& s)
@@ -119,19 +130,6 @@ void LLUriParser::fragment(const std::string& s)
mFragment = s;
}
-void LLUriParser::textRangeToString(UriTextRangeA& textRange, std::string& str)
-{
- if (textRange.first != NULL && textRange.afterLast != NULL && textRange.first < textRange.afterLast)
- {
- const ptrdiff_t len = textRange.afterLast - textRange.first;
- str.assign(textRange.first, static_cast<std::string::size_type>(len));
- }
- else
- {
- str = LLStringUtil::null;
- }
-}
-
void LLUriParser::extractParts()
{
if (mTmpScheme || mNormalizedTmp)
@@ -140,96 +138,24 @@ void LLUriParser::extractParts()
}
else
{
- textRangeToString(mUri.scheme, mScheme);
+ mScheme = mUri.scheme();
}
- textRangeToString(mUri.hostText, mHost);
- textRangeToString(mUri.portText, mPort);
- textRangeToString(mUri.query, mQuery);
- textRangeToString(mUri.fragment, mFragment);
-
- UriPathSegmentA * pathHead = mUri.pathHead;
- while (pathHead)
- {
- std::string partOfPath;
- textRangeToString(pathHead->text, partOfPath);
-
- mPath += '/';
- mPath += partOfPath;
-
- pathHead = pathHead->next;
- }
+ mHost = mUri.host();
+ mPort = mUri.port();
+ mQuery = mUri.query();
+ mFragment = mUri.fragment();
+ mPath = mUri.path();
}
-#if LL_DARWIN
-typedef void(*sighandler_t)(int);
-jmp_buf return_to_normalize;
-static int sLastSignal = 0;
-void uri_signal_handler(int signal)
-{
- sLastSignal = signal;
- // Apparently signal handler throwing an exception doesn't work.
- // This is ugly and unsafe due to not unwinding content of uriparser library,
- // but unless we have a way to catch this as NSexception, jump appears to be the only option.
- longjmp(return_to_normalize, 1 /*setjmp will return this value*/);
-}
-#endif
-
-S32 LLUriParser::normalize()
+bool LLUriParser::normalize()
{
mNormalizedTmp = mTmpScheme;
- if (!mRes)
+ if (mRes)
{
-#if LL_DARWIN
- sighandler_t last_sigill_handler, last_sigbus_handler;
- last_sigill_handler = signal(SIGILL, &uri_signal_handler); // illegal instruction
- last_sigbus_handler = signal(SIGBUS, &uri_signal_handler);
-
- if (setjmp(return_to_normalize))
- {
- // Issue: external library crashed via signal
- // If you encountered this, please try to figure out what's wrong:
- // 1. Verify that library's input is 'sane'
- // 2. Check if we have an NSexception to work with (unlikely)
- // 3. See if passing same string causes exception to repeat
- //
- // Crash happens at uriNormalizeSyntaxExA
- // Warning!!! This does not properly unwind stack,
- // if this can be handled by NSexception, it needs to be remade
- llassert(0);
-
- LL_WARNS() << "Uriparser crashed with " << sLastSignal << " , while processing: " << mNormalizedUri << LL_ENDL;
- signal(SIGILL, last_sigill_handler);
- signal(SIGBUS, last_sigbus_handler);
- return 1;
- }
-#endif
-
- mRes = uriNormalizeSyntaxExA(&mUri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
-
-#if LL_DARWIN
- signal(SIGILL, last_sigill_handler);
- signal(SIGBUS, last_sigbus_handler);
-#endif
-
- if (!mRes)
- {
- S32 chars_required;
- mRes = uriToStringCharsRequiredA(&mUri, &chars_required);
-
- if (!mRes)
- {
- chars_required++;
- std::vector<char> label_buf(chars_required);
- mRes = uriToStringA(&label_buf[0], &mUri, chars_required, NULL);
-
- if (!mRes)
- {
- mNormalizedUri = &label_buf[mTmpScheme ? 7 : 0];
- mTmpScheme = false;
- }
- }
- }
+ mUri.normalize_scheme().normalize_authority();
+ mNormalizedUri = mUri.buffer().substr(mTmpScheme ? 7 : 0);
+ mTmpScheme = false;
}
if(mTmpScheme && mNormalizedUri.size() > 7)
@@ -302,7 +228,7 @@ bool LLUriParser::test() const
return uri == mNormalizedUri;
}
-const char * LLUriParser::normalizedUri() const
+const std::string& LLUriParser::normalizedUri() const
{
- return mNormalizedUri.c_str();
+ return mNormalizedUri;
}
diff --git a/indra/llcommon/lluriparser.h b/indra/llcommon/lluriparser.h
index 77eb4031d5..61d613f399 100644
--- a/indra/llcommon/lluriparser.h
+++ b/indra/llcommon/lluriparser.h
@@ -30,7 +30,7 @@
#define LL_LLURIPARSER_H
#include <string>
-#include "uriparser/Uri.h"
+#include "boost/url.hpp"
class LL_COMMON_API LLUriParser
{
@@ -38,36 +38,35 @@ public:
LLUriParser(const std::string& u);
~LLUriParser();
- const char * scheme() const;
- void sheme (const std::string& s);
+ const std::string& scheme() const;
+ void scheme (const std::string& s);
- const char * port() const;
+ const std::string& port() const;
void port (const std::string& s);
- const char * host() const;
+ const std::string& host() const;
void host (const std::string& s);
- const char * path() const;
+ const std::string& path() const;
void path (const std::string& s);
- const char * query() const;
+ const std::string& query() const;
void query (const std::string& s);
- const char * fragment() const;
+ const std::string& fragment() const;
void fragment (const std::string& s);
- const char * normalizedUri() const;
+ const std::string& normalizedUri() const;
void extractParts();
void glue(std::string& uri) const;
void glueFirst(std::string& uri, bool use_scheme = true) const;
void glueSecond(std::string& uri) const;
bool test() const;
- S32 normalize();
+ bool normalize();
private:
- S32 parse();
- void textRangeToString(UriTextRangeA& textRange, std::string& str);
+ bool parse();
std::string mScheme;
std::string mHost;
std::string mPort;
@@ -76,9 +75,9 @@ private:
std::string mFragment;
std::string mNormalizedUri;
- UriUriA mUri;
+ boost::url mUri;
- S32 mRes;
+ bool mRes;
bool mTmpScheme;
bool mNormalizedTmp;
};
diff --git a/indra/llcorehttp/CMakeLists.txt b/indra/llcorehttp/CMakeLists.txt
index 5650c4c8ba..f7a6669825 100644
--- a/indra/llcorehttp/CMakeLists.txt
+++ b/indra/llcorehttp/CMakeLists.txt
@@ -158,7 +158,6 @@ if (DARWIN)
libapr-1.0.dylib
libaprutil-1.0.dylib
libnghttp2*.dylib
- liburiparser*.dylib
${EXPAT_COPY}
)
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 198441804b..79d2fcd049 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -239,7 +239,7 @@ std::string LLUrlEntryBase::urlToLabelWithGreyQuery(const std::string &url) cons
return url;
}
LLUriParser up(escapeUrl(url));
- if (up.normalize() == 0)
+ if (up.normalize())
{
std::string label;
up.extractParts();
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index 3a4ce6a72f..cec1ddfc57 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -221,7 +221,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
if (match_entry == mUrlEntryTrusted)
{
LLUriParser up(url);
- if (up.normalize() == 0)
+ if (up.normalize())
{
url = up.normalizedUri();
}
diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt
index def2d8f0c0..a34354d287 100644
--- a/indra/newview/CMakeLists.txt
+++ b/indra/newview/CMakeLists.txt
@@ -44,7 +44,6 @@ include(ViewerManager)
include(VisualLeakDetector)
include(VulkanGltf)
include(ZLIBNG)
-include(URIPARSER)
include(LLPrimitive)
if (NOT HAVOK_TPV)
@@ -1731,7 +1730,6 @@ if (WINDOWS)
${CMAKE_SOURCE_DIR}/../scripts/messages/message_template.msg
${SHARED_LIB_STAGING_DIR}/openjp2.dll
${SHARED_LIB_STAGING_DIR}/libhunspell.dll
- ${SHARED_LIB_STAGING_DIR}/uriparser.dll
${SHARED_LIB_STAGING_DIR}/llwebrtc.dll
#${SHARED_LIB_STAGING_DIR}/${LL_INTDIR}/SLVoice.exe
#${SHARED_LIB_STAGING_DIR}/${LL_INTDIR}/libsndfile-1.dll
diff --git a/indra/newview/llweb.cpp b/indra/newview/llweb.cpp
index d8852de954..a319aa00bc 100644
--- a/indra/newview/llweb.cpp
+++ b/indra/newview/llweb.cpp
@@ -50,7 +50,6 @@
#include "llviewerwindow.h"
#include "llnotificationsutil.h"
#include "lluriparser.h"
-#include "uriparser/Uri.h"
bool on_load_url_external_response(const LLSD& notification, const LLSD& response, bool async );
diff --git a/indra/newview/viewer_manifest.py b/indra/newview/viewer_manifest.py
index 5b6ac27575..a25efc5de4 100755
--- a/indra/newview/viewer_manifest.py
+++ b/indra/newview/viewer_manifest.py
@@ -561,9 +561,6 @@ class Windows_x86_64_Manifest(ViewerManifest):
# For textures
self.path("openjp2.dll")
- # Uriparser
- self.path("uriparser.dll")
-
# These need to be installed as a SxS assembly, currently a 'private' assembly.
# See http://msdn.microsoft.com/en-us/library/ms235291(VS.80).aspx
self.path("msvcp140.dll")
@@ -1022,7 +1019,6 @@ class Darwin_x86_64_Manifest(ViewerManifest):
# libnghttp2.major.dylib, which is a symlink to
# libnghttp2.version.dylib. Get all of them.
"libnghttp2.*dylib",
- "liburiparser.*dylib",
):
dylibs += path_optional(os.path.join(relpkgdir, libfile), libfile)