Update our url stuffs!

Adds support for JIRA link labels from Alchemy. (Made less of a mess by me)
Adds support for x-grid-info, the future of x-grid-info-location from Alchemy.
Updates uriparser latest from Alchemy.
Updates llstring to be more in line with upstream Alchemy.
Fixes our LLURI Implementation
Updates LLURLAction to modern C++ stuffies~
Adds Email protocol support from alchemy
Sync LLSLURL with Alchemy, adding x-grid-info support.
Also keep NoProtocol Support because yaaassss~
(also we won't suffer from MAINT-5019 because we're not dumb.)
This commit is contained in:
Lirusaito
2019-01-20 09:13:05 -05:00
parent 4b4c8c8e37
commit 7112e163e6
33 changed files with 1529 additions and 301 deletions

View File

@@ -1,3 +1,5 @@
// This is an open source non-commercial project. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
/**
* @file llstring.cpp
* @brief String utility functions and the std::string class.
@@ -28,12 +30,17 @@
#include "llstring.h"
#include "llerror.h"
#include "llfasttimer.h"
#include "llsd.h"
#if LL_WINDOWS
#include "llwin32headerslean.h"
#include <winnls.h> // for WideCharToMultiByte
#endif
LLTrace::BlockTimerStatHandle FT_STRING_FORMAT("String Format");
std::string ll_safe_string(const char* in)
{
if(in) return std::string(in);
@@ -47,6 +54,23 @@ std::string ll_safe_string(const char* in, S32 maxlen)
return std::string();
}
bool is_char_hex(char hex)
{
if((hex >= '0') && (hex <= '9'))
{
return true;
}
else if((hex >= 'a') && (hex <='f'))
{
return true;
}
else if((hex >= 'A') && (hex <='F'))
{
return true;
}
return false; // uh - oh, not hex any more...
}
U8 hex_as_nybble(char hex)
{
if((hex >= '0') && (hex <= '9'))
@@ -85,7 +109,7 @@ bool iswindividual(llwchar elem)
bool _read_file_into_string(std::string& str, const std::string& filename)
{
llifstream ifs(filename, llifstream::binary);
llifstream ifs(filename.c_str(), llifstream::binary);
if (!ifs.is_open())
{
LL_INFOS() << "Unable to open file " << filename << LL_ENDL;
@@ -552,6 +576,33 @@ std::string utf8str_truncate(const std::string& utf8str, const S32 max_len)
}
}
std::string utf8str_symbol_truncate(const std::string& utf8str, const S32 symbol_len)
{
if (0 == symbol_len)
{
return std::string();
}
if ((S32)utf8str.length() <= symbol_len)
{
return utf8str;
}
else
{
int len = 0, byteIndex = 0;
const char* aStr = utf8str.c_str();
size_t origSize = utf8str.size();
for (byteIndex = 0; len < symbol_len && byteIndex < origSize; byteIndex++)
{
if ((aStr[byteIndex] & 0xc0) != 0x80)
{
len += 1;
}
}
return utf8str.substr(0, byteIndex);
}
}
std::string utf8str_substChar(
const std::string& utf8str,
const llwchar target_char,
@@ -628,10 +679,10 @@ std::string ll_convert_wide_to_string(const wchar_t* in, unsigned int code_page)
0,
in,
len_in,
NULL,
nullptr,
0,
0,
0);
nullptr,
nullptr);
// We will need two more bytes for the double NULL ending
// created in WideCharToMultiByte().
char* pout = new char [len_out + 2];
@@ -645,8 +696,8 @@ std::string ll_convert_wide_to_string(const wchar_t* in, unsigned int code_page)
len_in,
pout,
len_out,
0,
0);
nullptr,
nullptr);
out.assign(pout);
delete[] pout;
}
@@ -667,8 +718,8 @@ wchar_t* ll_convert_string_to_wide(const std::string& in, unsigned int code_page
// reserve place to NULL terminator
int output_str_len = in.length();
wchar_t* w_out = new wchar_t[output_str_len + 1];
memset(w_out, 0, output_str_len + 1);
int real_output_str_len = MultiByteToWideChar (code_page, 0, in.c_str(), in.length(), w_out, output_str_len);
//looks like MultiByteToWideChar didn't add null terminator to converted string, see EXT-4858.
@@ -689,7 +740,7 @@ std::string ll_convert_string_to_utf8_string(const std::string& in)
long LLStringOps::sPacificTimeOffset = 0;
long LLStringOps::sLocalTimeOffset = 0;
bool LLStringOps::sPacificDaylightTime = 0;
bool LLStringOps::sPacificDaylightTime = false;
std::map<std::string, std::string> LLStringOps::datetimeToCodes;
std::vector<std::string> LLStringOps::sWeekDayList;
@@ -708,7 +759,7 @@ S32 LLStringOps::collate(const llwchar* a, const llwchar* b)
#if LL_WINDOWS
// in Windows, wide string functions operator on 16-bit strings,
// not the proper 32 bit wide string
return strcmp(wstring_to_utf8str(LLWString(a)).c_str(), wstring_to_utf8str(LLWString(b)).c_str());
return strcoll(wstring_to_utf8str(LLWString(a)).c_str(), wstring_to_utf8str(LLWString(b)).c_str());
#else
return wcscoll(a, b);
#endif
@@ -719,7 +770,7 @@ void LLStringOps::setupDatetimeInfo (bool daylight)
time_t nowT, localT, gmtT;
struct tm * tmpT;
nowT = time (NULL);
nowT = time (nullptr);
tmpT = gmtime (&nowT);
gmtT = mktime (tmpT);
@@ -799,7 +850,7 @@ void LLStringOps::setupDayFormat(const std::string& data)
}
std::string LLStringOps::getDatetimeCode (std::string key)
std::string LLStringOps::getDatetimeCode(const std::string& key)
{
std::map<std::string, std::string>::iterator iter;
@@ -1167,6 +1218,7 @@ bool LLStringUtil::formatDatetime(std::string& replacement, std::string token,
template<>
S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions)
{
LL_RECORD_BLOCK_TIME(FT_STRING_FORMAT);
S32 res = 0;
std::string output;
@@ -1239,6 +1291,7 @@ S32 LLStringUtil::format(std::string& s, const format_map_t& substitutions)
template<>
S32 LLStringUtil::format(std::string& s, const LLSD& substitutions)
{
LL_RECORD_BLOCK_TIME(FT_STRING_FORMAT);
S32 res = 0;
if (!substitutions.isMap())
@@ -1367,7 +1420,7 @@ void LLStringUtilBase<T>::testHarness()
s2.erase( 4, 1 );
llassert( s2 == "hell");
s2.insert( 0, 1, 'y' );
s2.insert( s2.begin(), 'y' );
llassert( s2 == "yhell");
s2.erase( 1, 3 );
llassert( s2 == "yl");