aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llurldispatcher.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-04-30 13:04:20 -0500
committerJacek Antonelli2009-04-30 13:07:16 -0500
commitca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch)
tree8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/newview/llurldispatcher.cpp
parentSecond Life viewer sources 1.22.11 (diff)
downloadmeta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2
meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/newview/llurldispatcher.cpp')
-rw-r--r--linden/indra/newview/llurldispatcher.cpp86
1 files changed, 57 insertions, 29 deletions
diff --git a/linden/indra/newview/llurldispatcher.cpp b/linden/indra/newview/llurldispatcher.cpp
index fd340c0..85ab44b 100644
--- a/linden/indra/newview/llurldispatcher.cpp
+++ b/linden/indra/newview/llurldispatcher.cpp
@@ -17,7 +17,8 @@
17 * There are special exceptions to the terms and conditions of the GPL as 17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception 18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or 19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception 20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 * 22 *
22 * By copying, modifying or distributing this software, you acknowledge 23 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above, 24 * that you have read and understood your obligations described above,
@@ -43,7 +44,6 @@
43#include "llpanellogin.h" 44#include "llpanellogin.h"
44#include "llstartup.h" // gStartupState 45#include "llstartup.h" // gStartupState
45#include "llurlsimstring.h" 46#include "llurlsimstring.h"
46#include "llviewerwindow.h" // alertXml()
47#include "llweb.h" 47#include "llweb.h"
48#include "llworldmap.h" 48#include "llworldmap.h"
49 49
@@ -64,26 +64,33 @@ public:
64 64
65 static bool isSLURLCommand(const std::string& url); 65 static bool isSLURLCommand(const std::string& url);
66 66
67 static bool dispatch(const std::string& url, bool from_external_browser); 67 static bool dispatch(const std::string& url,
68 LLWebBrowserCtrl* web,
69 bool trusted_browser);
68 // returns true if handled or explicitly blocked. 70 // returns true if handled or explicitly blocked.
69 71
70 static bool dispatchRightClick(const std::string& url); 72 static bool dispatchRightClick(const std::string& url);
71 73
72private: 74private:
73 static bool dispatchCore(const std::string& url, 75 static bool dispatchCore(const std::string& url,
74 bool from_external_browser, bool right_mouse); 76 bool right_mouse,
77 LLWebBrowserCtrl* web,
78 bool trusted_browser);
75 // handles both left and right click 79 // handles both left and right click
76 80
77 static bool dispatchHelp(const std::string& url, BOOL right_mouse); 81 static bool dispatchHelp(const std::string& url, bool right_mouse);
78 // Handles sl://app.floater.html.help by showing Help floater. 82 // Handles sl://app.floater.html.help by showing Help floater.
79 // Returns true if handled. 83 // Returns true if handled.
80 84
81 static bool dispatchApp(const std::string& url, bool from_external_browser, BOOL right_mouse); 85 static bool dispatchApp(const std::string& url,
86 bool right_mouse,
87 LLWebBrowserCtrl* web,
88 bool trusted_browser);
82 // Handles secondlife:///app/agent/<agent_id>/about and similar 89 // Handles secondlife:///app/agent/<agent_id>/about and similar
83 // by showing panel in Search floater. 90 // by showing panel in Search floater.
84 // Returns true if handled or explicitly blocked. 91 // Returns true if handled or explicitly blocked.
85 92
86 static bool dispatchRegion(const std::string& url, BOOL right_mouse); 93 static bool dispatchRegion(const std::string& url, bool right_mouse);
87 // handles secondlife://Ahern/123/45/67/ 94 // handles secondlife://Ahern/123/45/67/
88 // Returns true if handled. 95 // Returns true if handled.
89 96
@@ -127,41 +134,48 @@ bool LLURLDispatcherImpl::isSLURLCommand(const std::string& url)
127} 134}
128 135
129// static 136// static
130bool LLURLDispatcherImpl::dispatchCore(const std::string& url, bool from_external_browser, bool right_mouse) 137bool LLURLDispatcherImpl::dispatchCore(const std::string& url,
138 bool right_mouse,
139 LLWebBrowserCtrl* web,
140 bool trusted_browser)
131{ 141{
132 if (url.empty()) return false; 142 if (url.empty()) return false;
133 if (dispatchHelp(url, right_mouse)) return true; 143 if (dispatchHelp(url, right_mouse)) return true;
134 if (dispatchApp(url, from_external_browser, right_mouse)) return true; 144 if (dispatchApp(url, right_mouse, web, trusted_browser)) return true;
135 if (dispatchRegion(url, right_mouse)) return true; 145 if (dispatchRegion(url, right_mouse)) return true;
136 146
137 /* 147 /*
138 // Inform the user we can't handle this 148 // Inform the user we can't handle this
139 std::map<std::string, std::string> args; 149 std::map<std::string, std::string> args;
140 args["[SLURL]"] = url; 150 args["SLURL"] = url;
141 gViewerWindow->alertXml("BadURL", args); 151 r;
142 */ 152 */
143 153
144 return false; 154 return false;
145} 155}
146 156
147// static 157// static
148bool LLURLDispatcherImpl::dispatch(const std::string& url, bool from_external_browser) 158bool LLURLDispatcherImpl::dispatch(const std::string& url,
159 LLWebBrowserCtrl* web,
160 bool trusted_browser)
149{ 161{
150 llinfos << "url: " << url << llendl; 162 llinfos << "url: " << url << llendl;
151 const bool right_click = false; 163 const bool right_click = false;
152 return dispatchCore(url, from_external_browser, right_click); 164 return dispatchCore(url, right_click, web, trusted_browser);
153} 165}
154 166
155// static 167// static
156bool LLURLDispatcherImpl::dispatchRightClick(const std::string& url) 168bool LLURLDispatcherImpl::dispatchRightClick(const std::string& url)
157{ 169{
158 llinfos << "url: " << url << llendl; 170 llinfos << "url: " << url << llendl;
159 const bool from_external_browser = false;
160 const bool right_click = true; 171 const bool right_click = true;
161 return dispatchCore(url, from_external_browser, right_click); 172 LLWebBrowserCtrl* web = NULL;
173 const bool trusted_browser = false;
174 return dispatchCore(url, right_click, web, trusted_browser);
162} 175}
176
163// static 177// static
164bool LLURLDispatcherImpl::dispatchHelp(const std::string& url, BOOL right_mouse) 178bool LLURLDispatcherImpl::dispatchHelp(const std::string& url, bool right_mouse)
165{ 179{
166#if LL_LIBXUL_ENABLED 180#if LL_LIBXUL_ENABLED
167 if (matchPrefix(url, SLURL_SL_HELP_PREFIX)) 181 if (matchPrefix(url, SLURL_SL_HELP_PREFIX))
@@ -175,8 +189,9 @@ bool LLURLDispatcherImpl::dispatchHelp(const std::string& url, BOOL right_mouse)
175 189
176// static 190// static
177bool LLURLDispatcherImpl::dispatchApp(const std::string& url, 191bool LLURLDispatcherImpl::dispatchApp(const std::string& url,
178 bool from_external_browser, 192 bool right_mouse,
179 BOOL right_mouse) 193 LLWebBrowserCtrl* web,
194 bool trusted_browser)
180{ 195{
181 if (!isSLURL(url)) 196 if (!isSLURL(url))
182 { 197 {
@@ -189,12 +204,12 @@ bool LLURLDispatcherImpl::dispatchApp(const std::string& url,
189 std::string cmd = pathArray.get(0); 204 std::string cmd = pathArray.get(0);
190 pathArray.erase(0); // erase "cmd" 205 pathArray.erase(0); // erase "cmd"
191 bool handled = LLCommandDispatcher::dispatch( 206 bool handled = LLCommandDispatcher::dispatch(
192 cmd, from_external_browser, pathArray, uri.queryMap()); 207 cmd, pathArray, uri.queryMap(), web, trusted_browser);
193 return handled; 208 return handled;
194} 209}
195 210
196// static 211// static
197bool LLURLDispatcherImpl::dispatchRegion(const std::string& url, BOOL right_mouse) 212bool LLURLDispatcherImpl::dispatchRegion(const std::string& url, bool right_mouse)
198{ 213{
199 if (!isSLURL(url)) 214 if (!isSLURL(url))
200 { 215 {
@@ -359,10 +374,13 @@ std::string LLURLDispatcherImpl::stripProtocol(const std::string& url)
359class LLTeleportHandler : public LLCommandHandler 374class LLTeleportHandler : public LLCommandHandler
360{ 375{
361public: 376public:
362 // not allowed from outside the app 377 // Teleport requests *must* come from a trusted browser
363 LLTeleportHandler() : LLCommandHandler("teleport", false) { } 378 // inside the app, otherwise a malicious web page could
379 // cause a constant teleport loop. JC
380 LLTeleportHandler() : LLCommandHandler("teleport", true) { }
364 381
365 bool handle(const LLSD& tokens, const LLSD& queryMap) 382 bool handle(const LLSD& tokens, const LLSD& query_map,
383 LLWebBrowserCtrl* web)
366 { 384 {
367 // construct a "normal" SLURL, resolve the region to 385 // construct a "normal" SLURL, resolve the region to
368 // a global position, and teleport to it 386 // a global position, and teleport to it
@@ -401,10 +419,13 @@ bool LLURLDispatcher::isSLURLCommand(const std::string& url)
401} 419}
402 420
403// static 421// static
404bool LLURLDispatcher::dispatch(const std::string& url, bool from_external_browser) 422bool LLURLDispatcher::dispatch(const std::string& url,
423 LLWebBrowserCtrl* web,
424 bool trusted_browser)
405{ 425{
406 return LLURLDispatcherImpl::dispatch(url, from_external_browser); 426 return LLURLDispatcherImpl::dispatch(url, web, trusted_browser);
407} 427}
428
408// static 429// static
409bool LLURLDispatcher::dispatchRightClick(const std::string& url) 430bool LLURLDispatcher::dispatchRightClick(const std::string& url)
410{ 431{
@@ -414,13 +435,20 @@ bool LLURLDispatcher::dispatchRightClick(const std::string& url)
414// static 435// static
415bool LLURLDispatcher::dispatchFromTextEditor(const std::string& url) 436bool LLURLDispatcher::dispatchFromTextEditor(const std::string& url)
416{ 437{
417 // text editors are by definition internal to our code 438 // *NOTE: Text editors are considered sources of trusted URLs
418 const bool from_external_browser = false; 439 // in order to make objectim and avatar profile links in chat
419 return LLURLDispatcherImpl::dispatch(url, from_external_browser); 440 // history work. While a malicious resident could chat an app
441 // SLURL, the receiving resident will see it and must affirmatively
442 // click on it.
443 // *TODO: Make this trust model more refined. JC
444 const bool trusted_browser = true;
445 LLWebBrowserCtrl* web = NULL;
446 return LLURLDispatcherImpl::dispatch(url, web, trusted_browser);
420} 447}
421 448
422// static 449// static
423std::string LLURLDispatcher::buildSLURL(const std::string& regionname, S32 x, S32 y, S32 z) 450std::string LLURLDispatcher::buildSLURL(const std::string& regionname,
451 S32 x, S32 y, S32 z)
424{ 452{
425 std::string slurl = SLURL_SLURL_PREFIX + regionname + llformat("/%d/%d/%d",x,y,z); 453 std::string slurl = SLURL_SLURL_PREFIX + regionname + llformat("/%d/%d/%d",x,y,z);
426 slurl = LLWeb::escapeURL( slurl ); 454 slurl = LLWeb::escapeURL( slurl );