From 3af46da957cbc923d5847fba9d79f3186d832413 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Tue, 28 Jun 2016 19:32:10 +0200 Subject: [PATCH] FIRE-15972: Recognize InWorldz IZURLs properly --- indra/llcommon/lluri.cpp | 2 +- indra/llui/llurlentry.cpp | 16 +++++--- indra/newview/fsgridhandler.cpp | 6 ++- indra/newview/fsgridhandler.h | 3 ++ indra/newview/fsslurl.cpp | 69 ++++++++++++++++++++++++++++++--- indra/newview/fsslurl.h | 5 +++ 6 files changed, 87 insertions(+), 14 deletions(-) diff --git a/indra/llcommon/lluri.cpp b/indra/llcommon/lluri.cpp index 96e0c3f16f..db881954ba 100644 --- a/indra/llcommon/lluri.cpp +++ b/indra/llcommon/lluri.cpp @@ -261,7 +261,7 @@ static BOOL isDefault(const std::string& scheme, U16 port) void LLURI::parseAuthorityAndPathUsingOpaque() { - if (mScheme == "http" || mScheme == "https" || mScheme == "hop" || + if (mScheme == "http" || mScheme == "https" || mScheme == "hop" || mScheme == "inworldz" || mScheme == "iw" || mScheme == "ftp" || mScheme == "secondlife" || mScheme == "x-grid-location-info") { diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp index c8f971c299..e3b67ffd35 100644 --- a/indra/llui/llurlentry.cpp +++ b/indra/llui/llurlentry.cpp @@ -42,7 +42,7 @@ // hop:// protocol> //#define APP_HEADER_REGEX "((x-grid-location-info://[-\\w\\.]+/app)|(secondlife:///app))" -#define APP_HEADER_REGEX "(((hop|x-grid-location-info)://[-\\w\\.\\:\\@]+/app)|((hop|secondlife):///app))" +#define APP_HEADER_REGEX "(((hop|x-grid-location-info)://[-\\w\\.\\:\\@]+/app)|((hop|secondlife|inworldz|iw):///app))" // // Utility functions @@ -340,7 +340,9 @@ std::string LLUrlEntryHTTPNoProtocol::getTooltip(const std::string &url) const LLUrlEntryInvalidSLURL::LLUrlEntryInvalidSLURL() : LLUrlEntryBase() { - mPattern = boost::regex("(http://(maps.secondlife.com|slurl.com)/secondlife/|secondlife://(/app/(worldmap|teleport)/)?)[^ /]+(/-?[0-9]+){1,3}(/?(\\?title|\\?img|\\?msg)=\\S*)?/?", + // Inworldz special + //mPattern = boost::regex("(http://(maps.secondlife.com|slurl.com)/secondlife/|secondlife://(/app/(worldmap|teleport)/)?)[^ /]+(/-?[0-9]+){1,3}(/?(\\?title|\\?img|\\?msg)=\\S*)?/?", + mPattern = boost::regex("(http://(maps.secondlife.com|slurl.com)/secondlife/|(secondlife|inworldz|iw)://(/app/(worldmap|teleport)/)?)[^ /]+(/-?[0-9]+){1,3}(/?(\\?title|\\?img|\\?msg)=\\S*)?/?", boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_http.xml"; mTooltip = LLTrans::getString("TooltipHttpUrl"); @@ -1016,7 +1018,7 @@ LLUrlEntryObjectIM::LLUrlEntryObjectIM() { // hop:// protocol; Ansa: Stop at first space so we can use it in notifications! //mPattern = boost::regex("secondlife:///app/objectim/[\\da-f-]+\?.*", - mPattern = boost::regex("(hop|secondlife):///app/objectim/[\\da-f-]+\?[^ \t\r\n\v\f]*", + mPattern = boost::regex("(hop|secondlife|inworldz|iw):///app/objectim/[\\da-f-]+\?[^ \t\r\n\v\f]*", // boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_objectim.xml"; @@ -1145,7 +1147,9 @@ void LLUrlEntryParcel::processParcelInfo(const LLParcelData& parcel_data) // LLUrlEntryPlace::LLUrlEntryPlace() { - mPattern = boost::regex("((hop://[-\\w\\.\\:\\@]+/)|((x-grid-location-info://[-\\w\\.]+/region/)|(secondlife://)))\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?", // + // Inworldz special + //mPattern = boost::regex("((hop://[-\\w\\.\\:\\@]+/)|((x-grid-location-info://[-\\w\\.]+/region/)|(secondlife://)))\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?", // + mPattern = boost::regex("((hop://[-\\w\\.\\:\\@]+/)|((x-grid-location-info://[-\\w\\.]+/region/)|((secondlife|inworldz|iw)://)))\\S+/?(\\d+/\\d+/\\d+|\\d+/\\d+)/?", // boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_slurl.xml"; mTooltip = LLTrans::getString("TooltipSLURL"); @@ -1327,7 +1331,7 @@ std::string LLUrlEntryTeleport::getLocation(const std::string &url) const // LLUrlEntrySL::LLUrlEntrySL() { - mPattern = boost::regex("(hop|secondlife)://(\\w+)?(:\\d+)?/\\S+", // + mPattern = boost::regex("(hop|secondlife|inworldz|iw)://(\\w+)?(:\\d+)?/\\S+", // boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_slapp.xml"; mTooltip = LLTrans::getString("TooltipSLAPP"); @@ -1344,7 +1348,7 @@ std::string LLUrlEntrySL::getLabel(const std::string &url, const LLUrlLabelCallb // LLUrlEntrySLLabel::LLUrlEntrySLLabel() { - mPattern = boost::regex("\\[(hop|secondlife)://\\S+[ \t]+[^\\]]+\\]", // + mPattern = boost::regex("\\[(hop|secondlife|inworldz|iw)://\\S+[ \t]+[^\\]]+\\]", // boost::regex::perl|boost::regex::icase); mMenuName = "menu_url_slapp.xml"; mTooltip = LLTrans::getString("TooltipSLAPP"); diff --git a/indra/newview/fsgridhandler.cpp b/indra/newview/fsgridhandler.cpp index 1a3aa35046..482e29ff47 100644 --- a/indra/newview/fsgridhandler.cpp +++ b/indra/newview/fsgridhandler.cpp @@ -1432,6 +1432,10 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid) { ret = mGridList[grid][GRID_APP_SLURL_BASE].asString(); } + else if (grid == INWORLDZ_URI) + { + ret = "inworldz:///app"; + } else { std::string app_base; @@ -1463,6 +1467,6 @@ std::string LLGridManager::getAppSLURLBase(const std::string& grid) ret = llformat(app_base.c_str(), grid_norm.c_str()); } - LL_DEBUGS("GridManager") << "App slurl base: " << ret << LL_ENDL; + LL_DEBUGS("GridManager") << "App slurl base: " << ret << " - grid = " << grid << LL_ENDL; return ret; } diff --git a/indra/newview/fsgridhandler.h b/indra/newview/fsgridhandler.h index 7b293ebf07..9424787f57 100644 --- a/indra/newview/fsgridhandler.h +++ b/indra/newview/fsgridhandler.h @@ -70,6 +70,9 @@ const std::string GRID_SLURL_BASE = "slurl_base"; const std::string GRID_APP_SLURL_BASE = "app_slurl_base"; // +// Inworldz special +#define INWORLDZ_URI "inworldz.com:8002" + class GridInfoRequestResponder; // diff --git a/indra/newview/fsslurl.cpp b/indra/newview/fsslurl.cpp index 93b1b840c2..5307651f5b 100644 --- a/indra/newview/fsslurl.cpp +++ b/indra/newview/fsslurl.cpp @@ -52,14 +52,17 @@ const char* LLSLURL::SLURL_X_GRID_LOCATION_INFO_SCHEME = "x-grid-location-info"; const char* LLSLURL::WWW_SLURL_COM = "www.slurl.com"; const char* LLSLURL::MAPS_SECONDLIFE_COM = "maps.secondlife.com"; -// const char* LLSLURL::SLURL_COM = "slurl.com"; const char* LLSLURL::SLURL_APP_PATH = "app"; const char* LLSLURL::SLURL_SECONDLIFE_PATH = "secondlife"; const char* LLSLURL::SLURL_REGION_PATH = "region"; const char* LLSLURL::SIM_LOCATION_HOME = "home"; const char* LLSLURL::SIM_LOCATION_LAST = "last"; -// + +// Inworldz special +const char* LLSLURL::SLURL_INWORLDZ_SCHEME = "inworldz"; +const char* LLSLURL::SLURL_IW_SCHEME = "iw"; +const char* LLSLURL::PLACES_INWORLDZ_COM = "places.inworldz.com"; // resolve a simstring from a slurl LLSLURL::LLSLURL(const std::string& slurl) @@ -212,7 +215,7 @@ LLSLURL::LLSLURL(const std::string& slurl) if(mGrid.empty() && LLStartUp::getStartupState() == STATE_STARTED) { // we couldn't find the grid in the grid manager, so bail - LL_WARNS() << "unable to find grid" << LL_ENDL; + LL_WARNS("SLURL") << "unable to find grid" << LL_ENDL; return; } // set the type as appropriate. @@ -241,6 +244,55 @@ LLSLURL::LLSLURL(const std::string& slurl) path_array.insert(0, slurl_uri.hostNameAndPort()); } } + else if (slurl_uri.scheme() == LLSLURL::SLURL_INWORLDZ_SCHEME || + slurl_uri.scheme() == LLSLURL::SLURL_IW_SCHEME) + { + LL_DEBUGS("SLURL") << "inworldz scheme" << LL_ENDL; + + mGrid = INWORLDZ_URI; + + if (path_array[0].asString() == LLSLURL::SLURL_APP_PATH) + { + // it's in the form iw:///(app) + // so parse the grid name to derive the grid ID + if (!slurl_uri.hostNameAndPort().empty()) + { + LL_DEBUGS("SLURL") << "(inworldz|iw):///app" << LL_ENDL; + + mGrid = LLGridManager::getInstance()->getGridByProbing(slurl_uri.hostNameAndPort()); + if (mGrid.empty()) + { + mGrid = LLGridManager::getInstance()->getGridByProbing(slurl_uri.hostName()); + } + } + else if (path_array[0].asString() == LLSLURL::SLURL_APP_PATH) + { + LL_DEBUGS("SLURL") << "(inworldz|iw):///app" << LL_ENDL; + + // for app style slurls, where no grid name is specified, assume the currently + // selected or logged in grid. + mGrid = LLGridManager::getInstance()->getGridId(); + } + + if (mGrid.empty() && LLStartUp::getStartupState() == STATE_STARTED) + { + // we couldn't find the grid in the grid manager, so bail + LL_WARNS("SLURL")<<"unable to find grid"< or /app/, so it must be iw:// + // therefore the hostname will be the region name, and it's a location type + mType = LOCATION; + // 'normalize' it so the region name is in fact the head of the path_array + path_array.insert(0, slurl_uri.hostName()); + } + } else if((slurl_uri.scheme() == LLSLURL::SLURL_HTTP_SCHEME) || (slurl_uri.scheme() == LLSLURL::SLURL_HTTPS_SCHEME) || (slurl_uri.scheme() == LLSLURL::SLURL_X_GRID_LOCATION_INFO_SCHEME) @@ -257,6 +309,13 @@ LLSLURL::LLSLURL(const std::string& slurl) else mGrid = default_grid; } + // places.inworldz.com isn't your regular everyday slurl + else if (slurl_uri.hostName() == LLSLURL::PLACES_INWORLDZ_COM) + { + // likewise, places.inworldz.com implies inworldz and a location + mGrid = INWORLDZ_URI; + mType = LOCATION; + } else { LL_DEBUGS("SLURL") << "slurl style Standalone" << LL_ENDL; @@ -330,14 +389,12 @@ LLSLURL::LLSLURL(const std::string& slurl) path_array.erase(0); // leave app appended. } -// else if ( slurl_uri.scheme() == LLSLURL::HOP_SCHEME) { LL_DEBUGS("SLURL") << "It's a location hop" << LL_ENDL; mType = LOCATION; } -// - else + else if (slurl_uri.hostName() != LLSLURL::PLACES_INWORLDZ_COM) { LL_DEBUGS("SLURL") << "Not a valid https/http/x-grid-location-info slurl " << slurl << LL_ENDL; // not a valid https/http/x-grid-location-info slurl, so it'll likely just be a URL diff --git a/indra/newview/fsslurl.h b/indra/newview/fsslurl.h index c2b9808819..ef19cda080 100644 --- a/indra/newview/fsslurl.h +++ b/indra/newview/fsslurl.h @@ -53,6 +53,11 @@ public: static const char* SLURL_APP_PATH; static const char* SLURL_REGION_PATH; + // Inworldz special + static const char* SLURL_INWORLDZ_SCHEME; + static const char* SLURL_IW_SCHEME; + static const char* PLACES_INWORLDZ_COM; + enum SLURL_TYPE { INVALID,