summaryrefslogtreecommitdiff
path: root/indra/newview/llweb.cpp
blob: d57bb7da822d22ae68fd4a6b9372240e3da497f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/** 
 * @file llweb.cpp
 * @brief Functions dealing with web browsers
 * @author James Cook
 *
 * Copyright (c) 2006-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#include "llviewerprecompiledheaders.h"

#include "llweb.h"

#include "llwindow.h"

#include "llfloaterhtml.h"
#include "llviewercontrol.h"

// static
void LLWeb::loadURL(std::string url)
{
#if LL_MOZILLA_ENABLED
	if (gSavedSettings.getBOOL("UseExternalBrowser"))
	{
		loadURLExternal(url);
	}
	else
	{
		LLFloaterHTML::show((void*)url.c_str());
	}
#else
	loadURLExternal(url);
#endif
}


// static
void LLWeb::loadURLExternal(std::string url)
{
	std::string escaped_url = escapeURL(url);
	spawn_web_browser(escaped_url.c_str());
}


// static
std::string LLWeb::escapeURL(std::string url)
{
	// The CURL curl_escape() function escapes colons, slashes,
	// and all characters but A-Z and 0-9.  Do a cheesy mini-escape.
	std::string escaped_url;
	S32 len = url.length();
	for (S32 i = 0; i < len; i++)
	{
		char c = url[i];
		if (c == ' ')
		{
			escaped_url += "%20";
		}
		else if (c == '\\')
		{
			escaped_url += "%5C";
		}
		else
		{
			escaped_url += c;
		}
	}
	return escaped_url;
}