diff options
| author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2021-05-11 13:25:45 +0300 | 
|---|---|---|
| committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2021-05-11 13:25:45 +0300 | 
| commit | 713ab594d376c87e891647d8e2be013e4b9f92d8 (patch) | |
| tree | 353bff5ebb9a5e0e556e0241b89a4e154ef34616 | |
| parent | e886a5e34320c6448293dc05ac89a41b2b4a7f69 (diff) | |
| parent | c8c06400a6627053897d69f127e8699f89e503f7 (diff) | |
Merge branch 'DRTVWR-518-ui' of https://bitbucket.org/lindenlab/viewer/commits/branch/DRTVWR-518-ui into DRTVWR-518-ui
| -rw-r--r-- | indra/newview/llfloaterhowto.h | 6 | ||||
| -rw-r--r-- | indra/newview/llurlfloaterdispatchhandler.cpp | 56 | 
2 files changed, 35 insertions, 27 deletions
| diff --git a/indra/newview/llfloaterhowto.h b/indra/newview/llfloaterhowto.h index 15fc43335a..fa1d9cace0 100644 --- a/indra/newview/llfloaterhowto.h +++ b/indra/newview/llfloaterhowto.h @@ -42,12 +42,14 @@ public:      LLFloaterHowTo(const Params& key); -    /*virtual*/ void onOpen(const LLSD& key); +    void onOpen(const LLSD& key) override;      static LLFloaterHowTo* getInstance(); +    bool matchesKey(const LLSD& key) override { return true; /*single instance*/ }; +  private: -    /*virtual*/ BOOL postBuild(); +    BOOL postBuild() override;  };  #endif  // LL_LLFLOATERHOWTO_H diff --git a/indra/newview/llurlfloaterdispatchhandler.cpp b/indra/newview/llurlfloaterdispatchhandler.cpp index f03caf43b8..6de019d73c 100644 --- a/indra/newview/llurlfloaterdispatchhandler.cpp +++ b/indra/newview/llurlfloaterdispatchhandler.cpp @@ -52,8 +52,8 @@ const std::string KEY_URI("floater_url");  const std::string KEY_PARAMS("floater_params");  // Supported floaters, for now it's exact matching, later it might get extended -const std::string FLOATER_GUIDEBOOK("secondlife://guidebook"); // translates to "how_to" -const std::string FLOATER_WEB_CONTENT("secondlife://browser"); // translates to "web_content" +const std::string FLOATER_GUIDEBOOK("guidebook"); // translates to "how_to" +const std::string FLOATER_WEB_CONTENT("browser"); // translates to "web_content"  // Web content universal arguments  const std::string KEY_TRUSTED_CONTENT("trusted_content"); @@ -68,10 +68,6 @@ const std::string KEY_CAN_CLOSE("can_close");  const std::string KEY_SHOW_PAGE_TITLE("show_page_title");  const std::string KEY_ALLOW_ADRESS_ENTRY("allow_address_entry"); // It is not recomended to set this to true if trusted content is allowed -// expected format secondlife:///floater_alias -// intended to be extended to: secondlife:///floater_alias/instance_id -const boost::regex expression("secondlife:///[^ \n]{1,256}"); -  LLUrlFloaterDispatchHandler LLUrlFloaterDispatchHandler::sUrlDispatchhandler; @@ -112,7 +108,8 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st      std::string floater_title;      LLSD command_params; -    std::string floater_uri; +    std::string raw_uri; +    std::string floater_identifier;      if (message.has(KEY_ACTION) && message[KEY_ACTION].asString() == VALUE_OPEN_URL)      { @@ -121,14 +118,14 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st          {              floater_title = action_data[KEY_FLOATER_TITLE].asString();              command_params = action_data[KEY_PARAMS]; -            floater_uri = action_data[KEY_URI].asString(); +            raw_uri = action_data[KEY_URI].asString();          }      }      else if (message.has(KEY_FLOATER_TITLE))      {          floater_title = message[KEY_FLOATER_TITLE].asString();          command_params = message[KEY_PARAMS]; -        floater_uri = message[KEY_URI].asString(); +        raw_uri = message[KEY_URI].asString();      }      else      { @@ -136,16 +133,31 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st          return false;      } -    if (floater_uri.find(":///") == std::string::npos) +    if (raw_uri.find(":///") == std::string::npos)      {          // try unescaping -        floater_uri = LLURI::unescape(floater_uri); +        raw_uri = LLURI::unescape(raw_uri); +    } + +    LLURI floater_uri(raw_uri); +    if (floater_uri.scheme().empty() || floater_uri.scheme() != "secondlife") +    { +        LL_WARNS("URLFloater") << "Received " << raw_uri << " with unexpected scheme in uri: " << floater_uri << LL_ENDL; +        return false;      } -    boost::cmatch what; -    if (!boost::regex_match(floater_uri.c_str(), what, expression)) +    LLSD path_array = floater_uri.pathArray(); +    S32 path_parts = path_array.size(); +    if (path_parts == 0)      { -        LL_WARNS("URLFloater") << "Received " << MESSAGE_URL_FLOATER << " with invalid uri: " << floater_uri << LL_ENDL; +        LL_WARNS("URLFloater") << "received an empty uri: " << floater_uri << LL_ENDL; +        return false; +    } + +    floater_identifier = path_array[0]; +    if (floater_identifier.size() < 3) +    { +        LL_WARNS("URLFloater") << "received invalid flaoter indentifier: " << floater_identifier << LL_ENDL;          return false;      } @@ -162,7 +174,7 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st          }      } -    if (floater_uri == FLOATER_GUIDEBOOK) +    if (floater_identifier == FLOATER_GUIDEBOOK)      {          if (command_params.isMap()) // by default is undefines          { @@ -196,7 +208,7 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st              instance->setCanClose(command_params[KEY_CAN_CLOSE].asBoolean());          }      } -    else if (floater_uri == FLOATER_WEB_CONTENT) +    else if (floater_identifier == FLOATER_WEB_CONTENT)      {          if (command_params.has(KEY_URL))          { @@ -212,21 +224,15 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st      }      else      { -        LLSD path_array = LLURI(floater_uri).pathArray(); -        S32 path_parts = path_array.size(); -        if (path_parts == 0) -        { -            LL_INFOS("URLFloater") << "received an empty uri: " << floater_uri << LL_ENDL; -        } -        else if (LLFloaterReg::isRegistered(path_array[0])) +        if (LLFloaterReg::isRegistered(floater_identifier))          {              // A valid floater -            LL_INFOS("URLFloater") << "Floater " << path_array[0] << " is not supported by llopenfloater or URLFloater" << LL_ENDL; +            LL_INFOS("URLFloater") << "Floater " << floater_identifier << " is not supported by llopenfloater or URLFloater" << LL_ENDL;          }          else          {              // A valid message, but no such flaoter -            LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << floater_uri << LL_ENDL; +            LL_WARNS("URLFloater") << "Recieved a command to open unknown floater: " << raw_uri << LL_ENDL;          }      } | 
