diff options
| author | maksymsproductengine <maksymsproductengine@lindenlab.com> | 2014-09-24 23:09:30 +0300 | 
|---|---|---|
| committer | maksymsproductengine <maksymsproductengine@lindenlab.com> | 2014-09-24 23:09:30 +0300 | 
| commit | dd8d2b59f74ff01bd0b79b841e3974b3b00ddeb1 (patch) | |
| tree | eeef384b1ff5cf91ffa8b0f18943fd19658afb58 /indra | |
| parent | 2f08102780b1508563684b65a64e565caab7b143 (diff) | |
MAINT-4170 FIXED Eliminate homoglyphs in URL hostnames: converting to lowercase links without scheme
Diffstat (limited to 'indra')
| -rwxr-xr-x | indra/llui/lltextbase.cpp | 38 | 
1 files changed, 29 insertions, 9 deletions
| diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp index b9c3417dc8..8395e74715 100755 --- a/indra/llui/lltextbase.cpp +++ b/indra/llui/lltextbase.cpp @@ -2031,25 +2031,45 @@ S32 LLTextBase::normalizeUri(std::string& uri_string)  	if (!res)	  	{ -		res = uriNormalizeSyntaxExA(&uri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST); - -		if (!res) +		if (uri.scheme.afterLast - uri.scheme.first > 0)  		{ -			S32 chars_required; -			res = uriToStringCharsRequiredA(&uri, &chars_required); +			res = uriNormalizeSyntaxExA(&uri, URI_NORMALIZE_SCHEME | URI_NORMALIZE_HOST);  			if (!res)  			{ -				chars_required++; -				std::vector<char> label_buf(chars_required); -				res = uriToStringA(&label_buf[0], &uri, chars_required, NULL); +				S32 chars_required; +				res = uriToStringCharsRequiredA(&uri, &chars_required);  				if (!res)  				{ -					uri_string = &label_buf[0]; +					chars_required++; +					std::vector<char> label_buf(chars_required); +					res = uriToStringA(&label_buf[0], &uri, chars_required, NULL); + +					if (!res) +					{ +						uri_string = &label_buf[0]; +					}  				}  			}  		} +		else if (uri_string.find_first_of('.') != std::string::npos) +		{ +			static bool recursive_call = false; + +			// allow only single level recursive call +			if (!recursive_call) +			{ +				recursive_call = true; + +				// force uri to be with scheme and try to normalize +				std::string uri_with_scheme = "http://"; +				uri_with_scheme += uri_string; +				normalizeUri(uri_with_scheme); +				uri_string = uri_with_scheme.substr(7); +				recursive_call = false; +			}		 +		}  	}  	uriFreeUriMembersA(&uri); | 
