summaryrefslogtreecommitdiff
path: root/indra/newview/llweb.cpp
blob: 6ea9dfbbec774931ef4c6e127a73a58cec94da1d (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
/** 
 * @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)
{
	loadURLExternal(url);
}


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


// 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;
}