Skip to content
Snippets Groups Projects
Commit 61e05f91 authored by maksymsproductengine's avatar maksymsproductengine
Browse files

MAINT-4170 Eliminate homoglyphs in URL hostnames: used 3p-uriparser;

parent 9c4a8951
No related branches found
No related tags found
No related merge requests found
......@@ -1901,6 +1901,54 @@
</map>
</map>
</map>
<key>uriparser</key>
<map>
<key>license</key>
<string>uriparser</string>
<key>license_file</key>
<string>LICENSES/uriparser.txt</string>
<key>name</key>
<string>uriparser</string>
<key>platforms</key>
<map>
<key>darwin</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>99c5a966ac74eea5a505317396152168</string>
<key>url</key>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-uriparser/rev/294299/arch/Darwin/installer/uriparser-0.8.0.1-darwin-20140917.tar.bz2</string>
</map>
<key>name</key>
<string>darwin</string>
</map>
<key>linux</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>34306fb90364b182dc770375140d8557</string>
<key>url</key>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-uriparser/rev/294298/arch/Linux/installer/uriparser-0.8.0.1-linux-20140918.tar.bz2</string>
</map>
<key>name</key>
<string>linux</string>
</map>
<key>windows</key>
<map>
<key>archive</key>
<map>
<key>hash</key>
<string>73817db47bc0f87269861b7887319414</string>
<key>url</key>
<string>http://automated-builds-secondlife-com.s3.amazonaws.com/hg/repo/3p-uriparser/rev/294274/arch/CYGWIN/installer/uriparser-0.8.0.1-windows-20140917.tar.bz2</string>
</map>
<key>name</key>
<string>windows</string>
</map>
</map>
</map>
<key>xmlrpc-epi</key>
<map>
<key>license</key>
......
......@@ -37,6 +37,7 @@ set(cmake_SOURCE_FILES
FindNDOF.cmake
FindOpenJPEG.cmake
FindSCP.cmake
FindURIPARSER.cmake
FindXmlRpcEpi.cmake
FindZLIB.cmake
FMODEX.cmake
......@@ -97,6 +98,7 @@ set(cmake_SOURCE_FILES
Tut.cmake
UI.cmake
UnixInstall.cmake
URIPARSER.cmake
Variables.cmake
ViewerMiscLibs.cmake
VisualLeakDetector.cmake
......
# -*- cmake -*-
# - Find uriparser
# Find the URIPARSER includes and library
# This module defines
# URIPARSER_INCLUDE_DIRS, where to find uriparser.h, etc.
# URIPARSER_LIBRARIES, the libraries needed to use uriparser.
# URIPARSER_FOUND, If false, do not try to use uriparser.
#
# This FindURIPARSER is about 43 times as fast the one provided with cmake (2.8.x),
# because it doesn't look up the version of uriparser, resulting in a dramatic
# speed up for configure (from 4 minutes 22 seconds to 6 seconds).
#
# Note: Since this file is only used for standalone, the windows
# specific parts were left out.
FIND_PATH(URIPARSER_INCLUDE_DIR uriparser/uri.h
NO_SYSTEM_ENVIRONMENT_PATH
)
FIND_LIBRARY(URIPARSER_LIBRARY z)
if (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR)
SET(URIPARSER_INCLUDE_DIRS ${URIPARSER_INCLUDE_DIR})
SET(URIPARSER_LIBRARIES ${URIPARSER_LIBRARY})
SET(URIPARSER_FOUND "YES")
else (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR)
SET(URIPARSER_FOUND "NO")
endif (URIPARSER_LIBRARY AND URIPARSER_INCLUDE_DIR)
if (URIPARSER_FOUND)
if (NOT URIPARSER_FIND_QUIETLY)
message(STATUS "Found URIPARSER: ${URIPARSER_LIBRARIES}")
SET(URIPARSER_FIND_QUIETLY TRUE)
endif (NOT URIPARSER_FIND_QUIETLY)
else (URIPARSER_FOUND)
if (URIPARSER_FIND_REQUIRED)
message(FATAL_ERROR "Could not find URIPARSER library")
endif (URIPARSER_FIND_REQUIRED)
endif (URIPARSER_FOUND)
mark_as_advanced(
URIPARSER_LIBRARY
URIPARSER_INCLUDE_DIR
)
# -*- cmake -*-
set(URIPARSER_FIND_QUIETLY ON)
set(URIPARSER_FIND_REQUIRED ON)
include(Prebuilt)
if (STANDALONE)
include(FindURIPARSER)
else (STANDALONE)
use_prebuilt_binary(uriparser)
if (WINDOWS)
set(URIPARSER_LIBRARIES
debug uriparserd
optimized uriparser)
else (WINDOWS)
set(URIPARSER_LIBRARIES z)
endif (WINDOWS)
if (WINDOWS OR LINUX)
set(URIPARSER_INCLUDE_DIRS ${LIBS_PREBUILT_DIR}/include/uriparser)
endif (WINDOWS OR LINUX)
endif (STANDALONE)
......@@ -12,6 +12,7 @@ include(LLRender)
include(LLWindow)
include(LLVFS)
include(LLXML)
include(URIPARSER)
include_directories(
${LLCOMMON_INCLUDE_DIRS}
......@@ -28,6 +29,7 @@ include_directories(
include_directories(SYSTEM
${LLCOMMON_SYSTEM_INCLUDE_DIRS}
${LLXML_SYSTEM_INCLUDE_DIRS}
${URIPARSER_INCLUDE_DIRS}
)
set(llui_SOURCE_FILES
......@@ -278,6 +280,7 @@ target_link_libraries(llui
${LLXML_LIBRARIES}
${LLMATH_LIBRARIES}
${HUNSPELL_LIBRARY}
${URIPARSER_LIBRARIES}
${LLCOMMON_LIBRARIES} # must be after llimage, llwindow, llrender
)
......
......@@ -44,6 +44,8 @@
#include "llwindow.h"
#include <boost/bind.hpp>
#include "uriparser/Uri.h"
const F32 CURSOR_FLASH_DELAY = 1.0f; // in seconds
const S32 CURSOR_THICKNESS = 2;
const F32 TRIPLE_CLICK_INTERVAL = 0.3f; // delay between double and triple click.
......@@ -2019,6 +2021,41 @@ static LLUIImagePtr image_from_icon_name(const std::string& icon_name)
static LLTrace::BlockTimerStatHandle FTM_PARSE_HTML("Parse HTML");
S32 LLTextBase::normalizeUri(std::string& uri_string)
{
UriParserStateA state;
UriUriA uri;
state.uri = &uri;
S32 res = uriParseUriA(&state, uri_string.c_str());
if (!res)
{
res = uriNormalizeSyntaxExA(&uri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);
if (!res)
{
S32 chars_required;
res = uriToStringCharsRequiredA(&uri, &chars_required);
if (!res)
{
chars_required++;
std::vector<char> label_buf(chars_required);
res = uriToStringA(&label_buf[0], &uri, chars_required, NULL);
if (!res)
{
uri_string = &label_buf[0];
}
}
}
}
uriFreeUriMembersA(&uri);
return res;
}
void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params)
{
LLStyle::Params style_params(input_params);
......@@ -2055,8 +2092,12 @@ void LLTextBase::appendTextImpl(const std::string &new_text, const LLStyle::Para
std::string subtext=text.substr(0,start);
appendAndHighlightText(subtext, part, style_params);
}
std::string label = match.getLabel();
normalizeUri(label);
// output the styled Url
appendAndHighlightTextImpl(match.getLabel(), part, link_params, match.underlineOnHoverOnly());
appendAndHighlightTextImpl(label, part, link_params, match.underlineOnHoverOnly());
// set the tooltip for the Url label
if (! match.getTooltip().empty())
......
......@@ -590,6 +590,7 @@ class LLTextBase
void appendTextImpl(const std::string &new_text, const LLStyle::Params& input_params = LLStyle::Params());
void appendAndHighlightTextImpl(const std::string &new_text, S32 highlight_part, const LLStyle::Params& style_params, bool underline_on_hover_only = false);
S32 normalizeUri(std::string& uri);
protected:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment