diff options
Diffstat (limited to 'linden/indra/newview/llcommandhandler.cpp')
-rw-r--r-- | linden/indra/newview/llcommandhandler.cpp | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/linden/indra/newview/llcommandhandler.cpp b/linden/indra/newview/llcommandhandler.cpp index 154fc51..422c94a 100644 --- a/linden/indra/newview/llcommandhandler.cpp +++ b/linden/indra/newview/llcommandhandler.cpp | |||
@@ -19,7 +19,8 @@ | |||
19 | * There are special exceptions to the terms and conditions of the GPL as | 19 | * There are special exceptions to the terms and conditions of the GPL as |
20 | * it is applied to this Source Code. View the full text of the exception | 20 | * it is applied to this Source Code. View the full text of the exception |
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 21 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
22 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 22 | * online at |
23 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
23 | * | 24 | * |
24 | * By copying, modifying or distributing this software, you acknowledge | 25 | * By copying, modifying or distributing this software, you acknowledge |
25 | * that you have read and understood your obligations described above, | 26 | * that you have read and understood your obligations described above, |
@@ -42,7 +43,7 @@ | |||
42 | //--------------------------------------------------------------------------- | 43 | //--------------------------------------------------------------------------- |
43 | struct LLCommandHandlerInfo | 44 | struct LLCommandHandlerInfo |
44 | { | 45 | { |
45 | bool mAllowFromExternalBrowser; | 46 | bool mRequireTrustedBrowser; |
46 | LLCommandHandler* mHandler; // safe, all of these are static objects | 47 | LLCommandHandler* mHandler; // safe, all of these are static objects |
47 | }; | 48 | }; |
48 | 49 | ||
@@ -50,8 +51,12 @@ class LLCommandHandlerRegistry | |||
50 | { | 51 | { |
51 | public: | 52 | public: |
52 | static LLCommandHandlerRegistry& instance(); | 53 | static LLCommandHandlerRegistry& instance(); |
53 | void add(const char* cmd, bool allow_from_external_browser, LLCommandHandler* handler); | 54 | void add(const char* cmd, bool require_trusted_browser, LLCommandHandler* handler); |
54 | bool dispatch(const std::string& cmd, bool from_external_browser, const LLSD& params, const LLSD& queryMap); | 55 | bool dispatch(const std::string& cmd, |
56 | const LLSD& params, | ||
57 | const LLSD& query_map, | ||
58 | LLWebBrowserCtrl* web, | ||
59 | bool trusted_browser); | ||
55 | 60 | ||
56 | private: | 61 | private: |
57 | std::map<std::string, LLCommandHandlerInfo> mMap; | 62 | std::map<std::string, LLCommandHandlerInfo> mMap; |
@@ -67,40 +72,44 @@ LLCommandHandlerRegistry& LLCommandHandlerRegistry::instance() | |||
67 | return instance; | 72 | return instance; |
68 | } | 73 | } |
69 | 74 | ||
70 | void LLCommandHandlerRegistry::add(const char* cmd, bool allow_from_external_browser, LLCommandHandler* handler) | 75 | void LLCommandHandlerRegistry::add(const char* cmd, bool require_trusted_browser, LLCommandHandler* handler) |
71 | { | 76 | { |
72 | LLCommandHandlerInfo info; | 77 | LLCommandHandlerInfo info; |
73 | info.mAllowFromExternalBrowser = allow_from_external_browser; | 78 | info.mRequireTrustedBrowser = require_trusted_browser; |
74 | info.mHandler = handler; | 79 | info.mHandler = handler; |
75 | 80 | ||
76 | mMap[cmd] = info; | 81 | mMap[cmd] = info; |
77 | } | 82 | } |
78 | 83 | ||
79 | bool LLCommandHandlerRegistry::dispatch(const std::string& cmd, | 84 | bool LLCommandHandlerRegistry::dispatch(const std::string& cmd, |
80 | bool from_external_browser, | ||
81 | const LLSD& params, | 85 | const LLSD& params, |
82 | const LLSD& queryMap) | 86 | const LLSD& query_map, |
87 | LLWebBrowserCtrl* web, | ||
88 | bool trusted_browser) | ||
83 | { | 89 | { |
84 | std::map<std::string, LLCommandHandlerInfo>::iterator it = mMap.find(cmd); | 90 | std::map<std::string, LLCommandHandlerInfo>::iterator it = mMap.find(cmd); |
85 | if (it == mMap.end()) return false; | 91 | if (it == mMap.end()) return false; |
86 | const LLCommandHandlerInfo& info = it->second; | 92 | const LLCommandHandlerInfo& info = it->second; |
87 | if (from_external_browser && !info.mAllowFromExternalBrowser) | 93 | if (!trusted_browser && info.mRequireTrustedBrowser) |
88 | { | 94 | { |
89 | // block request from external browser, but report as | 95 | // block request from external browser, but report as |
90 | // "handled" because it was well formatted. | 96 | // "handled" because it was well formatted. |
97 | LL_WARNS_ONCE("SLURL") << "Blocked SLURL command from untrusted browser" << LL_ENDL; | ||
91 | return true; | 98 | return true; |
92 | } | 99 | } |
93 | if (!info.mHandler) return false; | 100 | if (!info.mHandler) return false; |
94 | return info.mHandler->handle(params, queryMap); | 101 | return info.mHandler->handle(params, query_map, web); |
95 | } | 102 | } |
96 | 103 | ||
97 | //--------------------------------------------------------------------------- | 104 | //--------------------------------------------------------------------------- |
98 | // Automatic registration of commands, runs before main() | 105 | // Automatic registration of commands, runs before main() |
99 | //--------------------------------------------------------------------------- | 106 | //--------------------------------------------------------------------------- |
100 | 107 | ||
101 | LLCommandHandler::LLCommandHandler(const char* cmd, bool allow_from_external_browser) | 108 | LLCommandHandler::LLCommandHandler(const char* cmd, |
109 | bool require_trusted_browser) | ||
102 | { | 110 | { |
103 | LLCommandHandlerRegistry::instance().add(cmd, allow_from_external_browser, this); | 111 | LLCommandHandlerRegistry::instance().add( |
112 | cmd, require_trusted_browser, this); | ||
104 | } | 113 | } |
105 | 114 | ||
106 | LLCommandHandler::~LLCommandHandler() | 115 | LLCommandHandler::~LLCommandHandler() |
@@ -115,9 +124,11 @@ LLCommandHandler::~LLCommandHandler() | |||
115 | 124 | ||
116 | // static | 125 | // static |
117 | bool LLCommandDispatcher::dispatch(const std::string& cmd, | 126 | bool LLCommandDispatcher::dispatch(const std::string& cmd, |
118 | bool from_external_browser, | 127 | const LLSD& params, |
119 | const LLSD& params, const LLSD& queryMap) | 128 | const LLSD& query_map, |
129 | LLWebBrowserCtrl* web, | ||
130 | bool trusted_browser) | ||
120 | { | 131 | { |
121 | return LLCommandHandlerRegistry::instance().dispatch( | 132 | return LLCommandHandlerRegistry::instance().dispatch( |
122 | cmd, from_external_browser, params, queryMap); | 133 | cmd, params, query_map, web, trusted_browser); |
123 | } | 134 | } |