Fixes for 'MAINT-8196 Remove LLPluginCookieStore from the viewer' and 'MAINT-8194 Remove per-frame calls to updateJavascriptObject()'

Wed, 17 Jan 2018 16:13:19 -0800

author
callum_linden
date
Wed, 17 Jan 2018 16:13:19 -0800
changeset 55061
844198571ed3
parent 55060
f4e0eedd5b1d
child 55062
217d363ff8b1

Fixes for 'MAINT-8196 Remove LLPluginCookieStore from the viewer' and 'MAINT-8194 Remove per-frame calls to updateJavascriptObject()'

indra/llplugin/CMakeLists.txt file | annotate | diff | revisions
indra/llplugin/llpluginclassmedia.cpp file | annotate | diff | revisions
indra/llplugin/llpluginclassmedia.h file | annotate | diff | revisions
indra/llplugin/llpluginclassmediaowner.h file | annotate | diff | revisions
indra/llplugin/llplugincookiestore.cpp file | annotate | diff | revisions
indra/llplugin/llplugincookiestore.h file | annotate | diff | revisions
indra/llplugin/tests/llplugincookiestore_test.cpp file | annotate | diff | revisions
indra/media_plugins/cef/media_plugin_cef.cpp file | annotate | diff | revisions
indra/newview/llappviewer.cpp file | annotate | diff | revisions
indra/newview/llfloaterfacebook.cpp file | annotate | diff | revisions
indra/newview/llfloaterflickr.cpp file | annotate | diff | revisions
indra/newview/llfloatertwitter.cpp file | annotate | diff | revisions
indra/newview/llstartup.cpp file | annotate | diff | revisions
indra/newview/llviewermedia.cpp file | annotate | diff | revisions
indra/newview/llviewermedia.h file | annotate | diff | revisions
indra/newview/llwebprofile.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llplugin/CMakeLists.txt	Thu Jan 11 10:32:23 2018 -0800
     1.2 +++ b/indra/llplugin/CMakeLists.txt	Wed Jan 17 16:13:19 2018 -0800
     1.3 @@ -29,7 +29,6 @@
     1.4  
     1.5  set(llplugin_SOURCE_FILES
     1.6      llpluginclassmedia.cpp
     1.7 -    llplugincookiestore.cpp
     1.8      llplugininstance.cpp
     1.9      llpluginmessage.cpp
    1.10      llpluginmessagepipe.cpp
    1.11 @@ -43,7 +42,6 @@
    1.12  
    1.13      llpluginclassmedia.h
    1.14      llpluginclassmediaowner.h
    1.15 -    llplugincookiestore.h
    1.16      llplugininstance.h
    1.17      llpluginmessage.h
    1.18      llpluginmessageclasses.h
    1.19 @@ -70,20 +68,3 @@
    1.20  
    1.21  add_subdirectory(slplugin)
    1.22  
    1.23 -# Add tests
    1.24 -if (LL_TESTS)
    1.25 -    include(LLAddBuildTest)
    1.26 -    # UNIT TESTS
    1.27 -    SET(llplugin_TEST_SOURCE_FILES
    1.28 -      llplugincookiestore.cpp
    1.29 -      )
    1.30 -
    1.31 -    # llplugincookiestore has a dependency on curl, so we need to link the curl library into the test.
    1.32 -    set_source_files_properties(
    1.33 -      llplugincookiestore.cpp
    1.34 -      PROPERTIES
    1.35 -        LL_TEST_ADDITIONAL_LIBRARIES "${CURL_LIBRARIES};${NGHTTP2_LIBRARIES}"
    1.36 -      )
    1.37 -
    1.38 -    LL_ADD_PROJECT_UNIT_TESTS(llplugin "${llplugin_TEST_SOURCE_FILES}")
    1.39 -endif (LL_TESTS)
     2.1 --- a/indra/llplugin/llpluginclassmedia.cpp	Thu Jan 11 10:32:23 2018 -0800
     2.2 +++ b/indra/llplugin/llpluginclassmedia.cpp	Wed Jan 17 16:13:19 2018 -0800
     2.3 @@ -1179,13 +1179,6 @@
     2.4  			mStatusCode = message.getValueS32("status_code");
     2.5  			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_NAVIGATE_ERROR_PAGE);
     2.6  		}
     2.7 -		else if(message_name == "cookie_set")
     2.8 -		{
     2.9 -			if(mOwner)
    2.10 -			{
    2.11 -				mOwner->handleCookieSet(this, message.getValue("cookie"));
    2.12 -			}
    2.13 -		}
    2.14  		else if(message_name == "close_request")
    2.15  		{
    2.16  			mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_CLOSE_REQUEST);
    2.17 @@ -1300,16 +1293,9 @@
    2.18  	sendMessage(message);
    2.19  }
    2.20  
    2.21 -void LLPluginClassMedia::set_cookies(const std::string &cookies)
    2.22 +void LLPluginClassMedia::cookies_enabled(bool enable)
    2.23  {
    2.24 -	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "set_cookies");
    2.25 -	message.setValue("cookies", cookies);
    2.26 -	sendMessage(message);
    2.27 -}
    2.28 -
    2.29 -void LLPluginClassMedia::enable_cookies(bool enable)
    2.30 -{
    2.31 -	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "enable_cookies");
    2.32 +	LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "cookies_enabled");
    2.33  	message.setValueBoolean("enable", enable);
    2.34  	sendMessage(message);
    2.35  }
     3.1 --- a/indra/llplugin/llpluginclassmedia.h	Thu Jan 11 10:32:23 2018 -0800
     3.2 +++ b/indra/llplugin/llpluginclassmedia.h	Wed Jan 17 16:13:19 2018 -0800
     3.3 @@ -210,7 +210,7 @@
     3.4  	void clear_cache();
     3.5  	void clear_cookies();
     3.6  	void set_cookies(const std::string &cookies);
     3.7 -	void enable_cookies(bool enable);
     3.8 +	void cookies_enabled(bool enable);
     3.9  	void proxy_setup(bool enable, const std::string &host = LLStringUtil::null, int port = 0);
    3.10  	void browse_stop();
    3.11  	void browse_reload(bool ignore_cache = false);
     4.1 --- a/indra/llplugin/llpluginclassmediaowner.h	Thu Jan 11 10:32:23 2018 -0800
     4.2 +++ b/indra/llplugin/llpluginclassmediaowner.h	Wed Jan 17 16:13:19 2018 -0800
     4.3 @@ -1,4 +1,4 @@
     4.4 -/** 
     4.5 +/**
     4.6   * @file llpluginclassmediaowner.h
     4.7   * @brief LLPluginClassMedia handles interaction with a plugin which knows about the "media" message class.
     4.8   *
     4.9 @@ -6,21 +6,21 @@
    4.10   * $LicenseInfo:firstyear=2008&license=viewerlgpl$
    4.11   * Second Life Viewer Source Code
    4.12   * Copyright (C) 2010, Linden Research, Inc.
    4.13 - * 
    4.14 + *
    4.15   * This library is free software; you can redistribute it and/or
    4.16   * modify it under the terms of the GNU Lesser General Public
    4.17   * License as published by the Free Software Foundation;
    4.18   * version 2.1 of the License only.
    4.19 - * 
    4.20 + *
    4.21   * This library is distributed in the hope that it will be useful,
    4.22   * but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.23   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.24   * Lesser General Public License for more details.
    4.25 - * 
    4.26 + *
    4.27   * You should have received a copy of the GNU Lesser General Public
    4.28   * License along with this library; if not, write to the Free Software
    4.29   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    4.30 - * 
    4.31 + *
    4.32   * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
    4.33   * $/LicenseInfo$
    4.34   * @endcond
    4.35 @@ -34,18 +34,17 @@
    4.36  #include <queue>
    4.37  
    4.38  class LLPluginClassMedia;
    4.39 -class LLPluginCookieStore;
    4.40  
    4.41  class LLPluginClassMediaOwner
    4.42  {
    4.43  public:
    4.44  	typedef enum
    4.45  	{
    4.46 -		MEDIA_EVENT_CONTENT_UPDATED,		// contents/dirty rect have updated 
    4.47 +		MEDIA_EVENT_CONTENT_UPDATED,		// contents/dirty rect have updated
    4.48  		MEDIA_EVENT_TIME_DURATION_UPDATED,	// current time and/or duration have updated
    4.49  		MEDIA_EVENT_SIZE_CHANGED,			// media size has changed
    4.50  		MEDIA_EVENT_CURSOR_CHANGED,			// plugin has requested a cursor change
    4.51 -		
    4.52 +
    4.53  		MEDIA_EVENT_NAVIGATE_BEGIN,			// browser has begun navigation
    4.54  		MEDIA_EVENT_NAVIGATE_COMPLETE,		// browser has finished navigation
    4.55  		MEDIA_EVENT_PROGRESS_UPDATED,		// browser has updated loading progress
    4.56 @@ -58,8 +57,8 @@
    4.57  		MEDIA_EVENT_CLOSE_REQUEST,			// The plugin requested its window be closed (currently hooked up to javascript window.close in webkit)
    4.58  		MEDIA_EVENT_PICK_FILE_REQUEST,		// The plugin wants the user to pick a file
    4.59  		MEDIA_EVENT_GEOMETRY_CHANGE,		// The plugin requested its window geometry be changed (per the javascript window interface)
    4.60 -	
    4.61 -		MEDIA_EVENT_PLUGIN_FAILED_LAUNCH,	// The plugin failed to launch 
    4.62 +
    4.63 +		MEDIA_EVENT_PLUGIN_FAILED_LAUNCH,	// The plugin failed to launch
    4.64  		MEDIA_EVENT_PLUGIN_FAILED,			// The plugin died unexpectedly
    4.65  
    4.66  		MEDIA_EVENT_AUTH_REQUEST,			// The plugin wants to display an auth dialog
    4.67 @@ -69,9 +68,9 @@
    4.68  		MEDIA_EVENT_DEBUG_MESSAGE,			// plugin sending back debug information for host to process
    4.69  
    4.70  		MEDIA_EVENT_LINK_HOVERED			// Got a "link hovered" event from the plugin
    4.71 -		
    4.72 +
    4.73  	} EMediaEvent;
    4.74 -	
    4.75 +
    4.76  	typedef enum
    4.77  	{
    4.78  		MEDIA_NONE,			// Uninitialized -- no useful state
    4.79 @@ -81,12 +80,11 @@
    4.80  		MEDIA_PLAYING,		// playing (only for time-based media)
    4.81  		MEDIA_PAUSED,		// paused (only for time-based media)
    4.82  		MEDIA_DONE			// finished playing (only for time-based media)
    4.83 -	
    4.84 +
    4.85  	} EMediaStatus;
    4.86 -	
    4.87 +
    4.88  	virtual ~LLPluginClassMediaOwner() {};
    4.89  	virtual void handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent /*event*/) {};
    4.90 -	virtual void handleCookieSet(LLPluginClassMedia* /*self*/, const std::string &/*cookie*/) {};
    4.91  };
    4.92  
    4.93  #endif // LL_LLPLUGINCLASSMEDIAOWNER_H
     5.1 --- a/indra/llplugin/llplugincookiestore.cpp	Thu Jan 11 10:32:23 2018 -0800
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,689 +0,0 @@
     5.4 -/** 
     5.5 - * @file llplugincookiestore.cpp
     5.6 - * @brief LLPluginCookieStore provides central storage for http cookies used by plugins
     5.7 - *
     5.8 - * @cond
     5.9 - * $LicenseInfo:firstyear=2010&license=viewerlgpl$
    5.10 - * Second Life Viewer Source Code
    5.11 - * Copyright (C) 2010, Linden Research, Inc.
    5.12 - * 
    5.13 - * This library is free software; you can redistribute it and/or
    5.14 - * modify it under the terms of the GNU Lesser General Public
    5.15 - * License as published by the Free Software Foundation;
    5.16 - * version 2.1 of the License only.
    5.17 - * 
    5.18 - * This library is distributed in the hope that it will be useful,
    5.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.21 - * Lesser General Public License for more details.
    5.22 - * 
    5.23 - * You should have received a copy of the GNU Lesser General Public
    5.24 - * License along with this library; if not, write to the Free Software
    5.25 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    5.26 - * 
    5.27 - * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
    5.28 - * $/LicenseInfo$
    5.29 - * @endcond
    5.30 - */
    5.31 -
    5.32 -#include "linden_common.h"
    5.33 -#include "llstl.h"
    5.34 -#include "indra_constants.h"
    5.35 -
    5.36 -#include "llplugincookiestore.h"
    5.37 -#include <iostream>
    5.38 -
    5.39 -// for curl_getdate() (apparently parsing RFC 1123 dates is hard)
    5.40 -#include <curl/curl.h>
    5.41 -
    5.42 -LLPluginCookieStore::LLPluginCookieStore():
    5.43 -	mHasChangedCookies(false)
    5.44 -{
    5.45 -}
    5.46 -
    5.47 -
    5.48 -LLPluginCookieStore::~LLPluginCookieStore()
    5.49 -{
    5.50 -	clearCookies();
    5.51 -}
    5.52 -
    5.53 -
    5.54 -LLPluginCookieStore::Cookie::Cookie(const std::string &s, std::string::size_type cookie_start, std::string::size_type cookie_end):
    5.55 -	mCookie(s, cookie_start, cookie_end - cookie_start),
    5.56 -	mNameStart(0), mNameEnd(0),
    5.57 -	mValueStart(0), mValueEnd(0),
    5.58 -	mDomainStart(0), mDomainEnd(0),
    5.59 -	mPathStart(0), mPathEnd(0),
    5.60 -	mDead(false), mChanged(true)
    5.61 -{
    5.62 -}
    5.63 -
    5.64 -LLPluginCookieStore::Cookie *LLPluginCookieStore::Cookie::createFromString(const std::string &s, std::string::size_type cookie_start, std::string::size_type cookie_end, const std::string &host)
    5.65 -{
    5.66 -	Cookie *result = new Cookie(s, cookie_start, cookie_end);
    5.67 -
    5.68 -	if(!result->parse(host))
    5.69 -	{
    5.70 -		delete result;
    5.71 -		result = NULL;
    5.72 -	}
    5.73 -	
    5.74 -	return result;
    5.75 -}
    5.76 -
    5.77 -std::string LLPluginCookieStore::Cookie::getKey() const
    5.78 -{
    5.79 -	std::string result;
    5.80 -	if(mDomainEnd > mDomainStart)
    5.81 -	{
    5.82 -		result += mCookie.substr(mDomainStart, mDomainEnd - mDomainStart);
    5.83 -	}
    5.84 -	result += ';';
    5.85 -	if(mPathEnd > mPathStart)
    5.86 -	{
    5.87 -		result += mCookie.substr(mPathStart, mPathEnd - mPathStart);
    5.88 -	}
    5.89 -	result += ';';
    5.90 -	result += mCookie.substr(mNameStart, mNameEnd - mNameStart);
    5.91 -	return result;
    5.92 -}
    5.93 -
    5.94 -std::string LLPluginCookieStore::Cookie::getDomain() const
    5.95 -{
    5.96 -	std::string result;
    5.97 -	if(mDomainEnd > mDomainStart)
    5.98 -	{
    5.99 -		result += mCookie.substr(mDomainStart, mDomainEnd - mDomainStart);
   5.100 -	}
   5.101 -	return result;
   5.102 -}
   5.103 -
   5.104 -bool LLPluginCookieStore::Cookie::parse(const std::string &host)
   5.105 -{
   5.106 -	bool first_field = true;
   5.107 -
   5.108 -	std::string::size_type cookie_end = mCookie.size();
   5.109 -	std::string::size_type field_start = 0;
   5.110 -
   5.111 -	LL_DEBUGS("CookieStoreParse") << "parsing cookie: " << mCookie << LL_ENDL;
   5.112 -	while(field_start < cookie_end)
   5.113 -	{
   5.114 -		// Finding the start of the next field requires honoring special quoting rules
   5.115 -		// see the definition of 'quoted-string' in rfc2616 for details
   5.116 -		std::string::size_type next_field_start = findFieldEnd(field_start);
   5.117 -
   5.118 -		// The end of this field should not include the terminating ';' or any trailing whitespace
   5.119 -		std::string::size_type field_end = mCookie.find_last_not_of("; ", next_field_start);
   5.120 -		if(field_end == std::string::npos || field_end < field_start)
   5.121 -		{
   5.122 -			// This field was empty or all whitespace.  Set end = start so it shows as empty.
   5.123 -			field_end = field_start;
   5.124 -		}
   5.125 -		else if (field_end < next_field_start)
   5.126 -		{
   5.127 -			// we actually want the index of the char _after_ what 'last not of' found
   5.128 -			++field_end;
   5.129 -		}
   5.130 -		
   5.131 -		// find the start of the actual name (skip separator and possible whitespace)
   5.132 -		std::string::size_type name_start = mCookie.find_first_not_of("; ", field_start);
   5.133 -		if(name_start == std::string::npos || name_start > next_field_start)
   5.134 -		{
   5.135 -			// Again, nothing but whitespace.
   5.136 -			name_start = field_start;
   5.137 -		}
   5.138 -		
   5.139 -		// the name and value are separated by the first equals sign
   5.140 -		std::string::size_type name_value_sep = mCookie.find_first_of("=", name_start);
   5.141 -		if(name_value_sep == std::string::npos || name_value_sep > field_end)
   5.142 -		{
   5.143 -			// No separator found, so this is a field without an = 
   5.144 -			name_value_sep = field_end;
   5.145 -		}
   5.146 -		
   5.147 -		// the name end is before the name-value separator
   5.148 -		std::string::size_type name_end = mCookie.find_last_not_of("= ", name_value_sep);
   5.149 -		if(name_end == std::string::npos || name_end < name_start)
   5.150 -		{
   5.151 -			// I'm not sure how we'd hit this case... it seems like it would have to be an empty name.
   5.152 -			name_end = name_start;
   5.153 -		}
   5.154 -		else if (name_end < name_value_sep)
   5.155 -		{
   5.156 -			// we actually want the index of the char _after_ what 'last not of' found
   5.157 -			++name_end;
   5.158 -		}
   5.159 -		
   5.160 -		// Value is between the name-value sep and the end of the field.
   5.161 -		std::string::size_type value_start = mCookie.find_first_not_of("= ", name_value_sep);
   5.162 -		if(value_start == std::string::npos || value_start > field_end)
   5.163 -		{
   5.164 -			// All whitespace or empty value
   5.165 -			value_start = field_end;
   5.166 -		}
   5.167 -		std::string::size_type value_end = mCookie.find_last_not_of("; ", field_end);
   5.168 -		if(value_end == std::string::npos || value_end < value_start)
   5.169 -		{
   5.170 -			// All whitespace or empty value
   5.171 -			value_end = value_start;
   5.172 -		}
   5.173 -		else if (value_end < field_end)
   5.174 -		{
   5.175 -			// we actually want the index of the char _after_ what 'last not of' found
   5.176 -			++value_end;
   5.177 -		}
   5.178 -
   5.179 -		LL_DEBUGS("CookieStoreParse") 
   5.180 -			<< "    field name: \"" << mCookie.substr(name_start, name_end - name_start) 
   5.181 -			<< "\", value: \"" << mCookie.substr(value_start, value_end - value_start) << "\""
   5.182 -			<< LL_ENDL;
   5.183 -				
   5.184 -		// See whether this field is one we know
   5.185 -		if(first_field)
   5.186 -		{
   5.187 -			// The first field is the name=value pair
   5.188 -			mNameStart = name_start;
   5.189 -			mNameEnd = name_end;
   5.190 -			mValueStart = value_start;
   5.191 -			mValueEnd = value_end;
   5.192 -			first_field = false;
   5.193 -		}
   5.194 -		else
   5.195 -		{
   5.196 -			// Subsequent fields must come from the set in rfc2109
   5.197 -			if(matchName(name_start, name_end, "expires"))
   5.198 -			{
   5.199 -				std::string date_string(mCookie, value_start, value_end - value_start); 
   5.200 -				// If the cookie contains an "expires" field, it MUST contain a parsable date.
   5.201 -				
   5.202 -				// HACK: LLDate apparently can't PARSE an rfc1123-format date, even though it can GENERATE one.
   5.203 -				//  The curl function curl_getdate can do this, but I'm hesitant to unilaterally introduce a curl dependency in LLDate.
   5.204 -#if 1
   5.205 -				time_t date = curl_getdate(date_string.c_str(), NULL );
   5.206 -				mDate.secondsSinceEpoch((F64)date);
   5.207 -				LL_DEBUGS("CookieStoreParse") << "        expire date parsed to: " << mDate.asRFC1123() << LL_ENDL;
   5.208 -#else
   5.209 -				// This doesn't work (rfc1123-format dates cause it to fail)
   5.210 -				if(!mDate.fromString(date_string))
   5.211 -				{
   5.212 -					// Date failed to parse.
   5.213 -					LL_WARNS("CookieStoreParse") << "failed to parse cookie's expire date: " << date << LL_ENDL;
   5.214 -					return false;
   5.215 -				}
   5.216 -#endif
   5.217 -			}
   5.218 -			else if(matchName(name_start, name_end, "domain"))
   5.219 -			{
   5.220 -				mDomainStart = value_start;
   5.221 -				mDomainEnd = value_end;
   5.222 -			}
   5.223 -			else if(matchName(name_start, name_end, "path"))
   5.224 -			{
   5.225 -				mPathStart = value_start;
   5.226 -				mPathEnd = value_end;
   5.227 -			}
   5.228 -			else if(matchName(name_start, name_end, "max-age"))
   5.229 -			{
   5.230 -				// TODO: how should we handle this?
   5.231 -			}
   5.232 -			else if(matchName(name_start, name_end, "secure"))
   5.233 -			{
   5.234 -				// We don't care about the value of this field (yet)
   5.235 -			}
   5.236 -			else if(matchName(name_start, name_end, "version"))
   5.237 -			{
   5.238 -				// We don't care about the value of this field (yet)
   5.239 -			}
   5.240 -			else if(matchName(name_start, name_end, "comment"))
   5.241 -			{
   5.242 -				// We don't care about the value of this field (yet)
   5.243 -			}
   5.244 -			else if(matchName(name_start, name_end, "httponly"))
   5.245 -			{
   5.246 -				// We don't care about the value of this field (yet)
   5.247 -			}
   5.248 -			else
   5.249 -			{
   5.250 -				// An unknown field is a parse failure
   5.251 -				LL_WARNS("CookieStoreParse") << "unexpected field name: " << mCookie.substr(name_start, name_end - name_start) << LL_ENDL;
   5.252 -				return false;
   5.253 -			}
   5.254 -			
   5.255 -		}
   5.256 -
   5.257 -		
   5.258 -		// move on to the next field, skipping this field's separator and any leading whitespace
   5.259 -		field_start = mCookie.find_first_not_of("; ", next_field_start);
   5.260 -	}
   5.261 -		
   5.262 -	// The cookie MUST have a name
   5.263 -	if(mNameEnd <= mNameStart)
   5.264 -		return false;
   5.265 -	
   5.266 -	// If the cookie doesn't have a domain, add the current host as the domain.
   5.267 -	if(mDomainEnd <= mDomainStart)
   5.268 -	{
   5.269 -		if(host.empty())
   5.270 -		{
   5.271 -			// no domain and no current host -- this is a parse failure.
   5.272 -			return false;
   5.273 -		}
   5.274 -		
   5.275 -		// Figure out whether this cookie ended with a ";" or not...
   5.276 -		std::string::size_type last_char = mCookie.find_last_not_of(" ");
   5.277 -		if((last_char != std::string::npos) && (mCookie[last_char] != ';'))
   5.278 -		{
   5.279 -			mCookie += ";";
   5.280 -		}
   5.281 -		
   5.282 -		mCookie += " domain=";
   5.283 -		mDomainStart = mCookie.size();
   5.284 -		mCookie += host;
   5.285 -		mDomainEnd = mCookie.size();
   5.286 -		
   5.287 -		LL_DEBUGS("CookieStoreParse") << "added domain (" << mDomainStart << " to " << mDomainEnd << "), new cookie is: " << mCookie << LL_ENDL;
   5.288 -	}
   5.289 -
   5.290 -	// If the cookie doesn't have a path, add "/".
   5.291 -	if(mPathEnd <= mPathStart)
   5.292 -	{
   5.293 -		// Figure out whether this cookie ended with a ";" or not...
   5.294 -		std::string::size_type last_char = mCookie.find_last_not_of(" ");
   5.295 -		if((last_char != std::string::npos) && (mCookie[last_char] != ';'))
   5.296 -		{
   5.297 -			mCookie += ";";
   5.298 -		}
   5.299 -		
   5.300 -		mCookie += " path=";
   5.301 -		mPathStart = mCookie.size();
   5.302 -		mCookie += "/";
   5.303 -		mPathEnd = mCookie.size();
   5.304 -		
   5.305 -		LL_DEBUGS("CookieStoreParse") << "added path (" << mPathStart << " to " << mPathEnd << "), new cookie is: " << mCookie << LL_ENDL;
   5.306 -	}
   5.307 -	
   5.308 -	
   5.309 -	return true;
   5.310 -}
   5.311 -
   5.312 -std::string::size_type LLPluginCookieStore::Cookie::findFieldEnd(std::string::size_type start, std::string::size_type end)
   5.313 -{
   5.314 -	std::string::size_type result = start;
   5.315 -	
   5.316 -	if(end == std::string::npos)
   5.317 -		end = mCookie.size();
   5.318 -	
   5.319 -	bool in_quotes = false;
   5.320 -	for(; (result < end); result++)
   5.321 -	{
   5.322 -		switch(mCookie[result])
   5.323 -		{
   5.324 -			case '\\':
   5.325 -				if(in_quotes)
   5.326 -					result++; // The next character is backslash-quoted.  Skip over it.
   5.327 -			break;
   5.328 -			case '"':
   5.329 -				in_quotes = !in_quotes;
   5.330 -			break;
   5.331 -			case ';':
   5.332 -				if(!in_quotes)
   5.333 -					return result;
   5.334 -			break;
   5.335 -		}		
   5.336 -	}
   5.337 -	
   5.338 -	// If we got here, no ';' was found.
   5.339 -	return end;
   5.340 -}
   5.341 -
   5.342 -bool LLPluginCookieStore::Cookie::matchName(std::string::size_type start, std::string::size_type end, const char *name)
   5.343 -{
   5.344 -	// NOTE: this assumes 'name' is already in lowercase.  The code which uses it should be able to arrange this...
   5.345 -	
   5.346 -	while((start < end) && (*name != '\0'))
   5.347 -	{
   5.348 -		if(tolower(mCookie[start]) != *name)
   5.349 -			return false;
   5.350 -			
   5.351 -		start++;
   5.352 -		name++;
   5.353 -	}
   5.354 -	
   5.355 -	// iff both strings hit the end at the same time, they're equal.
   5.356 -	return ((start == end) && (*name == '\0'));
   5.357 -}
   5.358 -
   5.359 -std::string LLPluginCookieStore::getAllCookies()
   5.360 -{
   5.361 -	std::stringstream result;
   5.362 -	writeAllCookies(result);
   5.363 -	return result.str();
   5.364 -}
   5.365 -
   5.366 -void LLPluginCookieStore::writeAllCookies(std::ostream& s)
   5.367 -{
   5.368 -	cookie_map_t::iterator iter;
   5.369 -	for(iter = mCookies.begin(); iter != mCookies.end(); iter++)
   5.370 -	{
   5.371 -		// Don't return expired cookies
   5.372 -		if(!iter->second->isDead())
   5.373 -		{
   5.374 -			s << (iter->second->getCookie()) << "\n";
   5.375 -		}
   5.376 -	}
   5.377 -
   5.378 -}
   5.379 -
   5.380 -std::string LLPluginCookieStore::getPersistentCookies()
   5.381 -{
   5.382 -	std::stringstream result;
   5.383 -	writePersistentCookies(result);
   5.384 -	return result.str();
   5.385 -}
   5.386 -
   5.387 -void LLPluginCookieStore::writePersistentCookies(std::ostream& s)
   5.388 -{
   5.389 -	cookie_map_t::iterator iter;
   5.390 -	for(iter = mCookies.begin(); iter != mCookies.end(); iter++)
   5.391 -	{
   5.392 -		// Don't return expired cookies or session cookies
   5.393 -		if(!iter->second->isDead() && !iter->second->isSessionCookie())
   5.394 -		{
   5.395 -			s << iter->second->getCookie() << "\n";
   5.396 -		}
   5.397 -	}
   5.398 -}
   5.399 -
   5.400 -std::string LLPluginCookieStore::getChangedCookies(bool clear_changed)
   5.401 -{
   5.402 -	std::stringstream result;
   5.403 -	writeChangedCookies(result, clear_changed);
   5.404 -	
   5.405 -	return result.str();
   5.406 -}
   5.407 -
   5.408 -void LLPluginCookieStore::writeChangedCookies(std::ostream& s, bool clear_changed)
   5.409 -{
   5.410 -	if(mHasChangedCookies)
   5.411 -	{
   5.412 -		LL_DEBUGS() << "returning changed cookies: " << LL_ENDL;
   5.413 -		cookie_map_t::iterator iter;
   5.414 -		for(iter = mCookies.begin(); iter != mCookies.end(); )
   5.415 -		{
   5.416 -			cookie_map_t::iterator next = iter;
   5.417 -			next++;
   5.418 -			
   5.419 -			// Only return cookies marked as "changed"
   5.420 -			if(iter->second->isChanged())
   5.421 -			{
   5.422 -				s << iter->second->getCookie() << "\n";
   5.423 -
   5.424 -				LL_DEBUGS() << "    " << iter->second->getCookie() << LL_ENDL;
   5.425 -
   5.426 -				// If requested, clear the changed mark
   5.427 -				if(clear_changed)
   5.428 -				{
   5.429 -					if(iter->second->isDead())
   5.430 -					{
   5.431 -						// If this cookie was previously marked dead, it needs to be removed entirely.	
   5.432 -						delete iter->second;
   5.433 -						mCookies.erase(iter);
   5.434 -					}
   5.435 -					else
   5.436 -					{
   5.437 -						// Not dead, just mark as not changed.
   5.438 -						iter->second->setChanged(false);
   5.439 -					}
   5.440 -				}
   5.441 -			}
   5.442 -			
   5.443 -			iter = next;
   5.444 -		}
   5.445 -	}
   5.446 -	
   5.447 -	if(clear_changed)
   5.448 -		mHasChangedCookies = false;
   5.449 -}
   5.450 -
   5.451 -void LLPluginCookieStore::setAllCookies(const std::string &cookies, bool mark_changed)
   5.452 -{
   5.453 -	clearCookies();
   5.454 -	setCookies(cookies, mark_changed);
   5.455 -}
   5.456 -
   5.457 -void LLPluginCookieStore::readAllCookies(std::istream& s, bool mark_changed)
   5.458 -{
   5.459 -	clearCookies();
   5.460 -	readCookies(s, mark_changed);
   5.461 -}
   5.462 -	
   5.463 -void LLPluginCookieStore::setCookies(const std::string &cookies, bool mark_changed)
   5.464 -{
   5.465 -	std::string::size_type start = 0;
   5.466 -
   5.467 -	while(start != std::string::npos)
   5.468 -	{
   5.469 -		std::string::size_type end = cookies.find_first_of("\r\n", start);
   5.470 -		if(end > start)
   5.471 -		{
   5.472 -			// The line is non-empty.  Try to create a cookie from it.
   5.473 -			setOneCookie(cookies, start, end, mark_changed);
   5.474 -		}
   5.475 -		start = cookies.find_first_not_of("\r\n ", end);
   5.476 -	}
   5.477 -}
   5.478 -
   5.479 -void LLPluginCookieStore::setCookiesFromHost(const std::string &cookies, const std::string &host, bool mark_changed)
   5.480 -{
   5.481 -	std::string::size_type start = 0;
   5.482 -
   5.483 -	while(start != std::string::npos)
   5.484 -	{
   5.485 -		std::string::size_type end = cookies.find_first_of("\r\n", start);
   5.486 -		if(end > start)
   5.487 -		{
   5.488 -			// The line is non-empty.  Try to create a cookie from it.
   5.489 -			setOneCookie(cookies, start, end, mark_changed, host);
   5.490 -		}
   5.491 -		start = cookies.find_first_not_of("\r\n ", end);
   5.492 -	}
   5.493 -}
   5.494 -			
   5.495 -void LLPluginCookieStore::readCookies(std::istream& s, bool mark_changed)
   5.496 -{
   5.497 -	std::string line;
   5.498 -	while(s.good() && !s.eof())
   5.499 -	{
   5.500 -		std::getline(s, line);
   5.501 -		if(!line.empty())
   5.502 -		{
   5.503 -			// Try to create a cookie from this line.
   5.504 -			setOneCookie(line, 0, std::string::npos, mark_changed);
   5.505 -		}
   5.506 -	}
   5.507 -}
   5.508 -
   5.509 -std::string LLPluginCookieStore::quoteString(const std::string &s)
   5.510 -{
   5.511 -	std::stringstream result;
   5.512 -	
   5.513 -	result << '"';
   5.514 -	
   5.515 -	for(std::string::size_type i = 0; i < s.size(); ++i)
   5.516 -	{
   5.517 -		char c = s[i];
   5.518 -		switch(c)
   5.519 -		{
   5.520 -			// All these separators need to be quoted in HTTP headers, according to section 2.2 of rfc 2616:
   5.521 -			case '(': case ')': case '<': case '>': case '@':
   5.522 -			case ',': case ';': case ':': case '\\': case '"':
   5.523 -			case '/': case '[': case ']': case '?': case '=':
   5.524 -			case '{': case '}':	case ' ': case '\t':
   5.525 -				result << '\\';
   5.526 -			break;
   5.527 -		}
   5.528 -		
   5.529 -		result << c;
   5.530 -	}
   5.531 -	
   5.532 -	result << '"';
   5.533 -	
   5.534 -	return result.str();
   5.535 -}
   5.536 -
   5.537 -std::string LLPluginCookieStore::unquoteString(const std::string &s)
   5.538 -{
   5.539 -	std::stringstream result;
   5.540 -	
   5.541 -	bool in_quotes = false;
   5.542 -	
   5.543 -	for(std::string::size_type i = 0; i < s.size(); ++i)
   5.544 -	{
   5.545 -		char c = s[i];
   5.546 -		switch(c)
   5.547 -		{
   5.548 -			case '\\':
   5.549 -				if(in_quotes)
   5.550 -				{
   5.551 -					// The next character is backslash-quoted.  Pass it through untouched.
   5.552 -					++i; 
   5.553 -					if(i < s.size())
   5.554 -					{
   5.555 -						result << s[i];
   5.556 -					}
   5.557 -					continue;
   5.558 -				}
   5.559 -			break;
   5.560 -			case '"':
   5.561 -				in_quotes = !in_quotes;
   5.562 -				continue;
   5.563 -			break;
   5.564 -		}
   5.565 -		
   5.566 -		result << c;
   5.567 -	}
   5.568 -	
   5.569 -	return result.str();
   5.570 -}
   5.571 -
   5.572 -// The flow for deleting a cookie is non-obvious enough that I should call it out here...
   5.573 -// Deleting a cookie is done by setting a cookie with the same name, path, and domain, but with an expire timestamp in the past.
   5.574 -// (This is exactly how a web server tells a browser to delete a cookie.)
   5.575 -// When deleting with mark_changed set to true, this replaces the existing cookie in the list with an entry that's marked both dead and changed.
   5.576 -// Some time later when writeChangedCookies() is called with clear_changed set to true, the dead cookie is deleted from the list after being returned, so that the
   5.577 -// delete operation (in the form of the expired cookie) is passed along.
   5.578 -void LLPluginCookieStore::setOneCookie(const std::string &s, std::string::size_type cookie_start, std::string::size_type cookie_end, bool mark_changed, const std::string &host)
   5.579 -{
   5.580 -	Cookie *cookie = Cookie::createFromString(s, cookie_start, cookie_end, host);
   5.581 -	if(cookie)
   5.582 -	{
   5.583 -		LL_DEBUGS("CookieStoreUpdate") << "setting cookie: " << cookie->getCookie() << LL_ENDL;
   5.584 -		
   5.585 -		// Create a key for this cookie
   5.586 -		std::string key = cookie->getKey();
   5.587 -		
   5.588 -		// Check to see whether this cookie should have expired
   5.589 -		if(!cookie->isSessionCookie() && (cookie->getDate() < LLDate::now()))
   5.590 -		{
   5.591 -			// This cookie has expired.
   5.592 -			if(mark_changed)
   5.593 -			{
   5.594 -				// If we're marking cookies as changed, we should keep it anyway since we'll need to send it out with deltas.
   5.595 -				cookie->setDead(true);
   5.596 -				LL_DEBUGS("CookieStoreUpdate") << "    marking dead" << LL_ENDL;
   5.597 -			}
   5.598 -			else
   5.599 -			{
   5.600 -				// If we're not marking cookies as changed, we don't need to keep this cookie at all.
   5.601 -				// If the cookie was already in the list, delete it.
   5.602 -				removeCookie(key);
   5.603 -
   5.604 -				delete cookie;
   5.605 -				cookie = NULL;
   5.606 -
   5.607 -				LL_DEBUGS("CookieStoreUpdate") << "    removing" << LL_ENDL;
   5.608 -			}
   5.609 -		}
   5.610 -		
   5.611 -		if(cookie)
   5.612 -		{
   5.613 -			// If it already exists in the map, replace it.
   5.614 -			cookie_map_t::iterator iter = mCookies.find(key);
   5.615 -			if(iter != mCookies.end())
   5.616 -			{
   5.617 -				if(iter->second->getCookie() == cookie->getCookie())
   5.618 -				{
   5.619 -					// The new cookie is identical to the old -- don't mark as changed.
   5.620 -					// Just leave the old one in the map.
   5.621 -					delete cookie;
   5.622 -					cookie = NULL;
   5.623 -
   5.624 -					LL_DEBUGS("CookieStoreUpdate") << "    unchanged" << LL_ENDL;
   5.625 -				}
   5.626 -				else
   5.627 -				{
   5.628 -					// A matching cookie was already in the map.  Replace it.
   5.629 -					delete iter->second;
   5.630 -					iter->second = cookie;
   5.631 -					
   5.632 -					cookie->setChanged(mark_changed);
   5.633 -					if(mark_changed)
   5.634 -						mHasChangedCookies = true;
   5.635 -
   5.636 -					LL_DEBUGS("CookieStoreUpdate") << "    replacing" << LL_ENDL;
   5.637 -				}
   5.638 -			}
   5.639 -			else
   5.640 -			{
   5.641 -				// The cookie wasn't in the map.  Insert it.
   5.642 -				mCookies.insert(std::make_pair(key, cookie));
   5.643 -				
   5.644 -				cookie->setChanged(mark_changed);
   5.645 -				if(mark_changed)
   5.646 -					mHasChangedCookies = true;
   5.647 -
   5.648 -				LL_DEBUGS("CookieStoreUpdate") << "    adding" << LL_ENDL;
   5.649 -			}
   5.650 -		}
   5.651 -	}
   5.652 -	else
   5.653 -	{
   5.654 -		LL_WARNS("CookieStoreUpdate") << "failed to parse cookie: " << s.substr(cookie_start, cookie_end - cookie_start) << LL_ENDL;
   5.655 -	}
   5.656 -
   5.657 -}
   5.658 -
   5.659 -void LLPluginCookieStore::clearCookies()
   5.660 -{
   5.661 -	std::for_each(mCookies.begin(), mCookies.end(), DeletePairedPointer());
   5.662 -	mCookies.clear();
   5.663 -}
   5.664 -
   5.665 -void LLPluginCookieStore::removeCookie(const std::string &key)
   5.666 -{
   5.667 -	cookie_map_t::iterator iter = mCookies.find(key);
   5.668 -	if(iter != mCookies.end())
   5.669 -	{
   5.670 -		delete iter->second;
   5.671 -		mCookies.erase(iter);
   5.672 -	}
   5.673 -}
   5.674 -
   5.675 -void LLPluginCookieStore::removeCookiesByDomain(const std::string &domain)
   5.676 -{
   5.677 -	cookie_map_t::iterator iter = mCookies.begin();
   5.678 -	while(iter != mCookies.end())
   5.679 -	{ 
   5.680 -		if(iter->second->getDomain() == domain)
   5.681 -		{
   5.682 -            cookie_map_t::iterator doErase = iter;
   5.683 -            iter++;
   5.684 -			delete doErase->second;
   5.685 -			mCookies.erase(doErase);
   5.686 -		}
   5.687 -        else
   5.688 -        {
   5.689 -            iter++;
   5.690 -        }
   5.691 -	}
   5.692 -}
     6.1 --- a/indra/llplugin/llplugincookiestore.h	Thu Jan 11 10:32:23 2018 -0800
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,123 +0,0 @@
     6.4 -/** 
     6.5 - * @file llplugincookiestore.h
     6.6 - * @brief LLPluginCookieStore provides central storage for http cookies used by plugins
     6.7 - *
     6.8 - * @cond
     6.9 - * $LicenseInfo:firstyear=2010&license=viewerlgpl$
    6.10 - * Second Life Viewer Source Code
    6.11 - * Copyright (C) 2010, Linden Research, Inc.
    6.12 - * 
    6.13 - * This library is free software; you can redistribute it and/or
    6.14 - * modify it under the terms of the GNU Lesser General Public
    6.15 - * License as published by the Free Software Foundation;
    6.16 - * version 2.1 of the License only.
    6.17 - * 
    6.18 - * This library is distributed in the hope that it will be useful,
    6.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.21 - * Lesser General Public License for more details.
    6.22 - * 
    6.23 - * You should have received a copy of the GNU Lesser General Public
    6.24 - * License along with this library; if not, write to the Free Software
    6.25 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    6.26 - * 
    6.27 - * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
    6.28 - * $/LicenseInfo$
    6.29 - * @endcond
    6.30 - */
    6.31 -
    6.32 -#ifndef LL_LLPLUGINCOOKIESTORE_H
    6.33 -#define LL_LLPLUGINCOOKIESTORE_H
    6.34 -
    6.35 -#include "lldate.h"
    6.36 -#include <map>
    6.37 -#include <string>
    6.38 -#include <iostream>
    6.39 -
    6.40 -class LLPluginCookieStore
    6.41 -{
    6.42 -	LOG_CLASS(LLPluginCookieStore);
    6.43 -public:
    6.44 -	LLPluginCookieStore();
    6.45 -	~LLPluginCookieStore();
    6.46 -
    6.47 -	// gets all cookies currently in storage -- use when initializing a plugin
    6.48 -	std::string getAllCookies();
    6.49 -	void writeAllCookies(std::ostream& s);
    6.50 -	
    6.51 -	// gets only persistent cookies (i.e. not session cookies) -- use when writing cookies to a file
    6.52 -	std::string getPersistentCookies();
    6.53 -	void writePersistentCookies(std::ostream& s);
    6.54 -	
    6.55 -	// gets cookies which are marked as "changed" -- use when sending periodic updates to plugins
    6.56 -	std::string getChangedCookies(bool clear_changed = true);
    6.57 -	void writeChangedCookies(std::ostream& s, bool clear_changed = true);
    6.58 -	
    6.59 -	// (re)initializes internal data structures and bulk-sets cookies -- use when reading cookies from a file
    6.60 -	void setAllCookies(const std::string &cookies, bool mark_changed = false);
    6.61 -	void readAllCookies(std::istream& s, bool mark_changed = false);
    6.62 -	
    6.63 -	// sets one or more cookies (without reinitializing anything) -- use when receiving cookies from a plugin
    6.64 -	void setCookies(const std::string &cookies, bool mark_changed = true);
    6.65 -	void readCookies(std::istream& s, bool mark_changed = true);
    6.66 -
    6.67 -	// sets one or more cookies (without reinitializing anything), supplying a hostname the cookies came from -- use when setting a cookie manually
    6.68 -	void setCookiesFromHost(const std::string &cookies, const std::string &host, bool mark_changed = true);
    6.69 -
    6.70 -	// quote or unquote a string as per the definition of 'quoted-string' in rfc2616
    6.71 -	static std::string quoteString(const std::string &s);
    6.72 -	static std::string unquoteString(const std::string &s);
    6.73 -
    6.74 -	void removeCookiesByDomain(const std::string &domain);
    6.75 -	
    6.76 -private:
    6.77 -
    6.78 -	void setOneCookie(const std::string &s, std::string::size_type cookie_start, std::string::size_type cookie_end, bool mark_changed, const std::string &host = LLStringUtil::null);
    6.79 -
    6.80 -	class Cookie
    6.81 -	{
    6.82 -	public:
    6.83 -		static Cookie *createFromString(const std::string &s, std::string::size_type cookie_start = 0, std::string::size_type cookie_end = std::string::npos, const std::string &host = LLStringUtil::null);
    6.84 -		
    6.85 -		// Construct a string from the cookie that uniquely represents it, to be used as a key in a std::map.
    6.86 -		std::string getKey() const;
    6.87 -		std::string getDomain() const;
    6.88 -		
    6.89 -		const std::string &getCookie() const { return mCookie; };
    6.90 -		bool isSessionCookie() const { return mDate.isNull(); };
    6.91 -
    6.92 -		bool isDead() const { return mDead; };
    6.93 -		void setDead(bool dead) { mDead = dead; };
    6.94 -		
    6.95 -		bool isChanged() const { return mChanged; };
    6.96 -		void setChanged(bool changed) { mChanged = changed; };
    6.97 -
    6.98 -		const LLDate &getDate() const { return mDate; };
    6.99 -		
   6.100 -	private:
   6.101 -		Cookie(const std::string &s, std::string::size_type cookie_start = 0, std::string::size_type cookie_end = std::string::npos);
   6.102 -		bool parse(const std::string &host);
   6.103 -		std::string::size_type findFieldEnd(std::string::size_type start = 0, std::string::size_type end = std::string::npos);
   6.104 -		bool matchName(std::string::size_type start, std::string::size_type end, const char *name);
   6.105 -		
   6.106 -		std::string mCookie;	// The full cookie, in RFC 2109 string format
   6.107 -		LLDate mDate;			// The expiration date of the cookie.  For session cookies, this will be a null date (mDate.isNull() is true).
   6.108 -		// Start/end indices of various parts of the cookie string.  Stored as indices into the string to save space and time.
   6.109 -		std::string::size_type mNameStart, mNameEnd;
   6.110 -		std::string::size_type mValueStart, mValueEnd;
   6.111 -		std::string::size_type mDomainStart, mDomainEnd;
   6.112 -		std::string::size_type mPathStart, mPathEnd;
   6.113 -		bool mDead;
   6.114 -		bool mChanged;
   6.115 -	};
   6.116 -	
   6.117 -	typedef std::map<std::string, Cookie*> cookie_map_t;
   6.118 -	
   6.119 -	cookie_map_t mCookies;
   6.120 -	bool mHasChangedCookies;
   6.121 -	
   6.122 -	void clearCookies();
   6.123 -	void removeCookie(const std::string &key);
   6.124 -};
   6.125 -
   6.126 -#endif // LL_LLPLUGINCOOKIESTORE_H
     7.1 --- a/indra/llplugin/tests/llplugincookiestore_test.cpp	Thu Jan 11 10:32:23 2018 -0800
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,207 +0,0 @@
     7.4 -/** 
     7.5 - * @file llplugincookiestore_test.cpp
     7.6 - * @brief Unit tests for LLPluginCookieStore.
     7.7 - *
     7.8 - * @cond
     7.9 - * $LicenseInfo:firstyear=2010&license=viewerlgpl$
    7.10 - * Second Life Viewer Source Code
    7.11 - * Copyright (C) 2010, Linden Research, Inc.
    7.12 - * 
    7.13 - * This library is free software; you can redistribute it and/or
    7.14 - * modify it under the terms of the GNU Lesser General Public
    7.15 - * License as published by the Free Software Foundation;
    7.16 - * version 2.1 of the License only.
    7.17 - * 
    7.18 - * This library is distributed in the hope that it will be useful,
    7.19 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.20 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.21 - * Lesser General Public License for more details.
    7.22 - * 
    7.23 - * You should have received a copy of the GNU Lesser General Public
    7.24 - * License along with this library; if not, write to the Free Software
    7.25 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
    7.26 - * 
    7.27 - * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
    7.28 - * $/LicenseInfo$
    7.29 - * @endcond
    7.30 - */
    7.31 -
    7.32 -#include "linden_common.h"
    7.33 -#include <list>
    7.34 -#include "../test/lltut.h"
    7.35 -
    7.36 -#include "../llplugincookiestore.h"
    7.37 -
    7.38 -
    7.39 -namespace tut
    7.40 -{
    7.41 -	// Main Setup
    7.42 -	struct LLPluginCookieStoreFixture
    7.43 -	{
    7.44 -		LLPluginCookieStoreFixture()
    7.45 -		{
    7.46 -			// We need dates definitively in the past and the future to properly test cookie expiration.
    7.47 -			LLDate now = LLDate::now(); 
    7.48 -			LLDate past(now.secondsSinceEpoch() - (60.0 * 60.0 * 24.0));	// 1 day in the past
    7.49 -			LLDate future(now.secondsSinceEpoch() + (60.0 * 60.0 * 24.0));	// 1 day in the future
    7.50 -			
    7.51 -			mPastString = past.asRFC1123();
    7.52 -			mFutureString = future.asRFC1123();
    7.53 -		}
    7.54 -		
    7.55 -		std::string mPastString;
    7.56 -		std::string mFutureString;
    7.57 -		LLPluginCookieStore mCookieStore;
    7.58 -		
    7.59 -		// List of cookies used for validation
    7.60 -		std::list<std::string> mCookies;
    7.61 -		
    7.62 -		// This sets up mCookies from a string returned by one of the functions in LLPluginCookieStore
    7.63 -		void setCookies(const std::string &cookies)
    7.64 -		{
    7.65 -			mCookies.clear();
    7.66 -			std::string::size_type start = 0;
    7.67 -
    7.68 -			while(start != std::string::npos)
    7.69 -			{
    7.70 -				std::string::size_type end = cookies.find_first_of("\r\n", start);
    7.71 -				if(end > start)
    7.72 -				{
    7.73 -					std::string line(cookies, start, end - start);
    7.74 -					if(line.find_first_not_of("\r\n\t ") != std::string::npos)
    7.75 -					{
    7.76 -						// The line has some non-whitespace characters.  Save it to the list.
    7.77 -						mCookies.push_back(std::string(cookies, start, end - start));
    7.78 -					}
    7.79 -				}
    7.80 -				start = cookies.find_first_not_of("\r\n ", end);
    7.81 -			}
    7.82 -		}
    7.83 -		
    7.84 -		// This ensures that a cookie matching the one passed is in the list.
    7.85 -		void ensureCookie(const std::string &cookie)
    7.86 -		{
    7.87 -			std::list<std::string>::iterator iter;
    7.88 -			for(iter = mCookies.begin(); iter != mCookies.end(); iter++)
    7.89 -			{
    7.90 -				if(*iter == cookie)
    7.91 -				{
    7.92 -					// Found the cookie
    7.93 -					// TODO: this should do a smarter equality comparison on the two cookies, instead of just a string compare.
    7.94 -					return;
    7.95 -				}
    7.96 -			}
    7.97 -			
    7.98 -			// Didn't find this cookie
    7.99 -			std::string message = "cookie not found: ";
   7.100 -			message += cookie;
   7.101 -			ensure(message, false);
   7.102 -		}
   7.103 -		
   7.104 -		// This ensures that the number of cookies in the list matches what's expected.
   7.105 -		void ensureSize(const std::string &message, size_t size)
   7.106 -		{
   7.107 -			if(mCookies.size() != size)
   7.108 -			{
   7.109 -				std::stringstream full_message;
   7.110 -				
   7.111 -				full_message << message << " (expected " << size << ", actual " << mCookies.size() << ")";
   7.112 -				ensure(full_message.str(), false);
   7.113 -			}
   7.114 -		}
   7.115 -	};
   7.116 -	
   7.117 -	typedef test_group<LLPluginCookieStoreFixture> factory;
   7.118 -	typedef factory::object object;
   7.119 -	factory tf("LLPluginCookieStore");
   7.120 -
   7.121 -	// Tests
   7.122 -	template<> template<>
   7.123 -	void object::test<1>()
   7.124 -	{
   7.125 -		// Test 1: cookie uniqueness and update lists.
   7.126 -		// Valid, distinct cookies:
   7.127 -		
   7.128 -		std::string cookie01 = "cookieA=value; domain=example.com; path=/";
   7.129 -		std::string cookie02 = "cookieB=value; Domain=example.com; Path=/; Max-Age=10; Secure; Version=1; Comment=foo!; HTTPOnly"; // cookie with every supported field, in different cases.
   7.130 -		std::string cookie03 = "cookieA=value; domain=foo.example.com; path=/"; // different domain
   7.131 -		std::string cookie04 = "cookieA=value; domain=example.com; path=/bar/"; // different path
   7.132 -		std::string cookie05 = "cookieC; domain=example.com; path=/"; // empty value
   7.133 -		std::string cookie06 = "cookieD=value; domain=example.com; path=/; expires="; // different name, persistent cookie
   7.134 -		cookie06 += mFutureString;
   7.135 -		
   7.136 -		mCookieStore.setCookies(cookie01);
   7.137 -		mCookieStore.setCookies(cookie02);
   7.138 -		mCookieStore.setCookies(cookie03);
   7.139 -		mCookieStore.setCookies(cookie04);
   7.140 -		mCookieStore.setCookies(cookie05);
   7.141 -		mCookieStore.setCookies(cookie06);
   7.142 -		
   7.143 -		// Invalid cookies (these will get parse errors and not be added to the store)
   7.144 -
   7.145 -		std::string badcookie01 = "cookieD=value; domain=example.com; path=/; foo=bar"; // invalid field name
   7.146 -		std::string badcookie02 = "cookieE=value; path=/"; // no domain
   7.147 -
   7.148 -		mCookieStore.setCookies(badcookie01);
   7.149 -		mCookieStore.setCookies(badcookie02);
   7.150 -		
   7.151 -		// All cookies added so far should have been marked as "changed"
   7.152 -		setCookies(mCookieStore.getChangedCookies());
   7.153 -		ensureSize("count of changed cookies", 6);
   7.154 -		ensureCookie(cookie01);
   7.155 -		ensureCookie(cookie02);
   7.156 -		ensureCookie(cookie03);
   7.157 -		ensureCookie(cookie04);
   7.158 -		ensureCookie(cookie05);
   7.159 -		ensureCookie(cookie06);
   7.160 -		
   7.161 -		// Save off the current state of the cookie store (we'll restore it later)
   7.162 -		std::string savedCookies = mCookieStore.getAllCookies();
   7.163 -		
   7.164 -		// Test replacing cookies
   7.165 -		std::string cookie01a = "cookieA=newvalue; domain=example.com; path=/";	// updated value
   7.166 -		std::string cookie02a = "cookieB=newvalue; domain=example.com; path=/; expires="; // remove cookie (by setting an expire date in the past)
   7.167 -		cookie02a += mPastString;
   7.168 -		
   7.169 -		mCookieStore.setCookies(cookie01a);
   7.170 -		mCookieStore.setCookies(cookie02a);
   7.171 -
   7.172 -		// test for getting changed cookies
   7.173 -		setCookies(mCookieStore.getChangedCookies());
   7.174 -		ensureSize("count of updated cookies", 2);
   7.175 -		ensureCookie(cookie01a);
   7.176 -		ensureCookie(cookie02a);
   7.177 -		
   7.178 -		// and for the state of the store after getting changed cookies
   7.179 -		setCookies(mCookieStore.getAllCookies());
   7.180 -		ensureSize("count of valid cookies", 5);
   7.181 -		ensureCookie(cookie01a);
   7.182 -		ensureCookie(cookie03);
   7.183 -		ensureCookie(cookie04);
   7.184 -		ensureCookie(cookie05);
   7.185 -		ensureCookie(cookie06);
   7.186 -
   7.187 -		// Check that only the persistent cookie is returned here
   7.188 -		setCookies(mCookieStore.getPersistentCookies());
   7.189 -		ensureSize("count of persistent cookies", 1);
   7.190 -		ensureCookie(cookie06);
   7.191 -
   7.192 -		// Restore the cookie store to a previous state and verify
   7.193 -		mCookieStore.setAllCookies(savedCookies);
   7.194 -		
   7.195 -		// Since setAllCookies defaults to not marking cookies as changed, this list should be empty.
   7.196 -		setCookies(mCookieStore.getChangedCookies());
   7.197 -		ensureSize("count of changed cookies after restore", 0);
   7.198 -
   7.199 -		// Verify that the restore worked as it should have.
   7.200 -		setCookies(mCookieStore.getAllCookies());
   7.201 -		ensureSize("count of restored cookies", 6);
   7.202 -		ensureCookie(cookie01);
   7.203 -		ensureCookie(cookie02);
   7.204 -		ensureCookie(cookie03);
   7.205 -		ensureCookie(cookie04);
   7.206 -		ensureCookie(cookie05);
   7.207 -		ensureCookie(cookie06);
   7.208 -	}
   7.209 -
   7.210 -}
     8.1 --- a/indra/media_plugins/cef/media_plugin_cef.cpp	Thu Jan 11 10:32:23 2018 -0800
     8.2 +++ b/indra/media_plugins/cef/media_plugin_cef.cpp	Wed Jan 17 16:13:19 2018 -0800
     8.3 @@ -747,6 +747,10 @@
     8.4  			{
     8.5  				mCookiesEnabled = message_in.getValueBoolean("enable");
     8.6  			}
     8.7 +			else if (message_name == "clear_cookies")
     8.8 +			{
     8.9 +				mCEFLib->deleteAllCookies();
    8.10 +			}
    8.11  			else if (message_name == "set_user_agent")
    8.12  			{
    8.13  				mUserAgentSubtring = message_in.getValue("user_agent");
     9.1 --- a/indra/newview/llappviewer.cpp	Thu Jan 11 10:32:23 2018 -0800
     9.2 +++ b/indra/newview/llappviewer.cpp	Wed Jan 17 16:13:19 2018 -0800
     9.3 @@ -1940,8 +1940,6 @@
     9.4  
     9.5  	LLAvatarIconIDCache::getInstance()->save();
     9.6  	
     9.7 -	LLViewerMedia::saveCookieFile();
     9.8 -
     9.9  	// Stop the plugin read thread if it's running.
    9.10  	LLPluginProcessParent::setUseReadThread(false);
    9.11  
    10.1 --- a/indra/newview/llfloaterfacebook.cpp	Thu Jan 11 10:32:23 2018 -0800
    10.2 +++ b/indra/newview/llfloaterfacebook.cpp	Wed Jan 17 16:13:19 2018 -0800
    10.3 @@ -1,4 +1,4 @@
    10.4 -/** 
    10.5 +/**
    10.6  * @file llfloaterfacebook.cpp
    10.7  * @brief Implementation of llfloaterfacebook
    10.8  * @author Gilbert@lindenlab.com
    10.9 @@ -41,7 +41,6 @@
   10.10  #include "llresmgr.h"		// LLLocale
   10.11  #include "llsdserialize.h"
   10.12  #include "llloadingindicator.h"
   10.13 -#include "llplugincookiestore.h"
   10.14  #include "llslurl.h"
   10.15  #include "lltrans.h"
   10.16  #include "llsnapshotlivepreview.h"
   10.17 @@ -296,16 +295,11 @@
   10.18  void LLFacebookStatusPanel::onConnect()
   10.19  {
   10.20      LLFacebookConnect::instance().checkConnectionToFacebook(true);
   10.21 -
   10.22 -    //Clear only the facebook browser cookies so that the facebook login screen appears
   10.23 -    LLViewerMedia::getCookieStore()->removeCookiesByDomain(".facebook.com");
   10.24  }
   10.25  
   10.26  void LLFacebookStatusPanel::onDisconnect()
   10.27  {
   10.28      LLFacebookConnect::instance().disconnectFromFacebook();
   10.29 -
   10.30 -    LLViewerMedia::getCookieStore()->removeCookiesByDomain(".facebook.com");
   10.31  }
   10.32  
   10.33  void LLFacebookStatusPanel::clearAndClose()
   10.34 @@ -810,7 +804,7 @@
   10.35      LLAgentUI::buildSLURL(slurl);
   10.36      std::string slurl_string = slurl.getSLURLString();
   10.37  
   10.38 -    // Use a valid http:// URL if the scheme is secondlife:// 
   10.39 +    // Use a valid http:// URL if the scheme is secondlife://
   10.40      LLURI slurl_uri(slurl_string);
   10.41      if (slurl_uri.scheme() == LLSLURL::SLURL_SECONDLIFE_SCHEME)
   10.42      {
    11.1 --- a/indra/newview/llfloaterflickr.cpp	Thu Jan 11 10:32:23 2018 -0800
    11.2 +++ b/indra/newview/llfloaterflickr.cpp	Wed Jan 17 16:13:19 2018 -0800
    11.3 @@ -40,7 +40,6 @@
    11.4  #include "llresmgr.h"		// LLLocale
    11.5  #include "llsdserialize.h"
    11.6  #include "llloadingindicator.h"
    11.7 -#include "llplugincookiestore.h"
    11.8  #include "llslurl.h"
    11.9  #include "lltrans.h"
   11.10  #include "llsnapshotlivepreview.h"
   11.11 @@ -660,16 +659,11 @@
   11.12  void LLFlickrAccountPanel::onConnect()
   11.13  {
   11.14  	LLFlickrConnect::instance().checkConnectionToFlickr(true);
   11.15 -
   11.16 -	//Clear only the flickr browser cookies so that the flickr login screen appears
   11.17 -	LLViewerMedia::getCookieStore()->removeCookiesByDomain(".flickr.com"); 
   11.18  }
   11.19  
   11.20  void LLFlickrAccountPanel::onDisconnect()
   11.21  {
   11.22  	LLFlickrConnect::instance().disconnectFromFlickr();
   11.23 -
   11.24 -	LLViewerMedia::getCookieStore()->removeCookiesByDomain(".flickr.com"); 
   11.25  }
   11.26  
   11.27  ////////////////////////
    12.1 --- a/indra/newview/llfloatertwitter.cpp	Thu Jan 11 10:32:23 2018 -0800
    12.2 +++ b/indra/newview/llfloatertwitter.cpp	Wed Jan 17 16:13:19 2018 -0800
    12.3 @@ -41,7 +41,6 @@
    12.4  #include "llresmgr.h"		// LLLocale
    12.5  #include "llsdserialize.h"
    12.6  #include "llloadingindicator.h"
    12.7 -#include "llplugincookiestore.h"
    12.8  #include "llslurl.h"
    12.9  #include "lltrans.h"
   12.10  #include "llsnapshotlivepreview.h"
   12.11 @@ -684,16 +683,11 @@
   12.12  void LLTwitterAccountPanel::onConnect()
   12.13  {
   12.14  	LLTwitterConnect::instance().checkConnectionToTwitter(true);
   12.15 -
   12.16 -	//Clear only the twitter browser cookies so that the twitter login screen appears
   12.17 -	LLViewerMedia::getCookieStore()->removeCookiesByDomain(".twitter.com"); 
   12.18  }
   12.19  
   12.20  void LLTwitterAccountPanel::onDisconnect()
   12.21  {
   12.22  	LLTwitterConnect::instance().disconnectFromTwitter();
   12.23 -
   12.24 -	LLViewerMedia::getCookieStore()->removeCookiesByDomain(".twitter.com"); 
   12.25  }
   12.26  
   12.27  ////////////////////////
    13.1 --- a/indra/newview/llstartup.cpp	Thu Jan 11 10:32:23 2018 -0800
    13.2 +++ b/indra/newview/llstartup.cpp	Wed Jan 17 16:13:19 2018 -0800
    13.3 @@ -965,9 +965,6 @@
    13.4  		// Load Avatars icons cache
    13.5  		LLAvatarIconIDCache::getInstance()->load();
    13.6  		
    13.7 -		// Load media plugin cookies
    13.8 -		LLViewerMedia::loadCookieFile();
    13.9 -
   13.10  		LLRenderMuteList::getInstance()->loadFromFile();
   13.11  
   13.12  		//-------------------------------------------------
    14.1 --- a/indra/newview/llviewermedia.cpp	Thu Jan 11 10:32:23 2018 -0800
    14.2 +++ b/indra/newview/llviewermedia.cpp	Wed Jan 17 16:13:19 2018 -0800
    14.3 @@ -50,7 +50,6 @@
    14.4  #include "llpanelprofile.h"
    14.5  #include "llparcel.h"
    14.6  #include "llpluginclassmedia.h"
    14.7 -#include "llplugincookiestore.h"
    14.8  #include "llurldispatcher.h"
    14.9  #include "lluuid.h"
   14.10  #include "llversioninfo.h"
   14.11 @@ -154,7 +153,6 @@
   14.12  }
   14.13  
   14.14  
   14.15 -LLPluginCookieStore *LLViewerMedia::sCookieStore = NULL;
   14.16  LLURL LLViewerMedia::sOpenIDURL;
   14.17  std::string LLViewerMedia::sOpenIDCookie;
   14.18  LLPluginClassMedia* LLViewerMedia::sSpareBrowserMediaSource = NULL;
   14.19 @@ -169,8 +167,6 @@
   14.20  static bool sAnyMediaShowing = false;
   14.21  static bool sAnyMediaPlaying = false;
   14.22  static boost::signals2::connection sTeleportFinishConnection;
   14.23 -static std::string sUpdatedCookies;
   14.24 -static const char *PLUGIN_COOKIE_FILE_NAME = "plugin_cookies.txt";
   14.25  
   14.26  //////////////////////////////////////////////////////////////////////////////////////////
   14.27  static void add_media_impl(LLViewerMediaImpl* media)
   14.28 @@ -610,12 +606,6 @@
   14.29  
   14.30  	sAnyMediaShowing = false;
   14.31  	sAnyMediaPlaying = false;
   14.32 -	sUpdatedCookies = getCookieStore()->getChangedCookies();
   14.33 -	if(!sUpdatedCookies.empty())
   14.34 -	{
   14.35 -		LL_DEBUGS() << "updated cookies will be sent to all loaded plugins: " << LL_ENDL;
   14.36 -		LL_DEBUGS() << sUpdatedCookies << LL_ENDL;
   14.37 -	}
   14.38  
   14.39  	impl_list::iterator iter = sViewerMediaImplList.begin();
   14.40  	impl_list::iterator end = sViewerMediaImplList.end();
   14.41 @@ -1048,64 +1038,6 @@
   14.42  			pimpl->mMediaSource->clear_cookies();
   14.43  		}
   14.44  	}
   14.45 -
   14.46 -	// Clear all cookies from the cookie store
   14.47 -	getCookieStore()->setAllCookies("");
   14.48 -
   14.49 -	// FIXME: this may not be sufficient, since the on-disk cookie file won't get written until some browser instance exits cleanly.
   14.50 -	// It also won't clear cookies for other accounts, or for any account if we're not logged in, and won't do anything at all if there are no webkit plugins loaded.
   14.51 -	// Until such time as we can centralize cookie storage, the following hack should cover these cases:
   14.52 -
   14.53 -	// HACK: Look for cookie files in all possible places and delete them.
   14.54 -	// NOTE: this assumes knowledge of what happens inside the webkit plugin (it's what adds 'browser_profile' to the path and names the cookie file)
   14.55 -
   14.56 -	// Places that cookie files can be:
   14.57 -	// <getOSUserAppDir>/browser_profile/cookies
   14.58 -	// <getOSUserAppDir>/first_last/browser_profile/cookies  (note that there may be any number of these!)
   14.59 -	// <getOSUserAppDir>/first_last/plugin_cookies.txt  (note that there may be any number of these!)
   14.60 -
   14.61 -	std::string base_dir = gDirUtilp->getOSUserAppDir() + gDirUtilp->getDirDelimiter();
   14.62 -	std::string target;
   14.63 -	std::string filename;
   14.64 -
   14.65 -	LL_DEBUGS() << "base dir = " << base_dir << LL_ENDL;
   14.66 -
   14.67 -	// The non-logged-in version is easy
   14.68 -	target = base_dir;
   14.69 -	target += "browser_profile";
   14.70 -	target += gDirUtilp->getDirDelimiter();
   14.71 -	target += "cookies";
   14.72 -	LL_DEBUGS() << "target = " << target << LL_ENDL;
   14.73 -	if(LLFile::isfile(target))
   14.74 -	{
   14.75 -		LLFile::remove(target);
   14.76 -	}
   14.77 -
   14.78 -	// the hard part: iterate over all user directories and delete the cookie file from each one
   14.79 -	LLDirIterator dir_iter(base_dir, "*_*");
   14.80 -	while (dir_iter.next(filename))
   14.81 -	{
   14.82 -		target = gDirUtilp->add(base_dir, filename);
   14.83 -		gDirUtilp->append(target, "browser_profile");
   14.84 -		gDirUtilp->append(target, "cookies");
   14.85 -		LL_DEBUGS() << "target = " << target << LL_ENDL;
   14.86 -		if(LLFile::isfile(target))
   14.87 -		{
   14.88 -			LLFile::remove(target);
   14.89 -		}
   14.90 -
   14.91 -		// Other accounts may have new-style cookie files too -- delete them as well
   14.92 -		target = gDirUtilp->add(base_dir, filename);
   14.93 -		gDirUtilp->append(target, PLUGIN_COOKIE_FILE_NAME);
   14.94 -		LL_DEBUGS() << "target = " << target << LL_ENDL;
   14.95 -		if(LLFile::isfile(target))
   14.96 -		{
   14.97 -			LLFile::remove(target);
   14.98 -		}
   14.99 -	}
  14.100 -
  14.101 -	// If we have an OpenID cookie, re-add it to the cookie store.
  14.102 -	setOpenIDCookie(std::string());
  14.103  }
  14.104  
  14.105  /////////////////////////////////////////////////////////////////////////////////////////
  14.106 @@ -1134,7 +1066,7 @@
  14.107  		LLViewerMediaImpl* pimpl = *iter;
  14.108  		if(pimpl->mMediaSource)
  14.109  		{
  14.110 -			pimpl->mMediaSource->enable_cookies(enabled);
  14.111 +			pimpl->mMediaSource->cookies_enabled(enabled);
  14.112  		}
  14.113  	}
  14.114  }
  14.115 @@ -1159,127 +1091,7 @@
  14.116  /////////////////////////////////////////////////////////////////////////////////////////
  14.117  // static
  14.118  /////////////////////////////////////////////////////////////////////////////////////////
  14.119 -// static
  14.120 -LLPluginCookieStore *LLViewerMedia::getCookieStore()
  14.121 -{
  14.122 -	if(sCookieStore == NULL)
  14.123 -	{
  14.124 -		sCookieStore = new LLPluginCookieStore;
  14.125 -	}
  14.126 -
  14.127 -	return sCookieStore;
  14.128 -}
  14.129 -
  14.130 -/////////////////////////////////////////////////////////////////////////////////////////
  14.131 -// static
  14.132 -void LLViewerMedia::loadCookieFile()
  14.133 -{
  14.134 -	// build filename for each user
  14.135 -	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PLUGIN_COOKIE_FILE_NAME);
  14.136 -
  14.137 -	if (resolved_filename.empty())
  14.138 -	{
  14.139 -		LL_INFOS() << "can't get path to plugin cookie file - probably not logged in yet." << LL_ENDL;
  14.140 -		return;
  14.141 -	}
  14.142 -
  14.143 -	// open the file for reading
  14.144 -	llifstream file(resolved_filename.c_str());
  14.145 -	if (!file.is_open())
  14.146 -	{
  14.147 -		LL_WARNS() << "can't load plugin cookies from file \"" << PLUGIN_COOKIE_FILE_NAME << "\"" << LL_ENDL;
  14.148 -		return;
  14.149 -	}
  14.150 -
  14.151 -	getCookieStore()->readAllCookies(file, true);
  14.152 -
  14.153 -	file.close();
  14.154 -
  14.155 -	// send the clear_cookies message to all loaded plugins
  14.156 -	impl_list::iterator iter = sViewerMediaImplList.begin();
  14.157 -	impl_list::iterator end = sViewerMediaImplList.end();
  14.158 -	for (; iter != end; iter++)
  14.159 -	{
  14.160 -		LLViewerMediaImpl* pimpl = *iter;
  14.161 -		if(pimpl->mMediaSource)
  14.162 -		{
  14.163 -			pimpl->mMediaSource->clear_cookies();
  14.164 -		}
  14.165 -	}
  14.166 -
  14.167 -	// If we have an OpenID cookie, re-add it to the cookie store.
  14.168 -	setOpenIDCookie(std::string());
  14.169 -}
  14.170 -
  14.171 -
  14.172 -/////////////////////////////////////////////////////////////////////////////////////////
  14.173 -// static
  14.174 -void LLViewerMedia::saveCookieFile()
  14.175 -{
  14.176 -	// build filename for each user
  14.177 -	std::string resolved_filename = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, PLUGIN_COOKIE_FILE_NAME);
  14.178 -
  14.179 -	if (resolved_filename.empty())
  14.180 -	{
  14.181 -		LL_INFOS() << "can't get path to plugin cookie file - probably not logged in yet." << LL_ENDL;
  14.182 -		return;
  14.183 -	}
  14.184 -
  14.185 -	// open a file for writing
  14.186 -	llofstream file(resolved_filename.c_str());
  14.187 -	if (!file.is_open())
  14.188 -	{
  14.189 -		LL_WARNS() << "can't open plugin cookie file \"" << PLUGIN_COOKIE_FILE_NAME << "\" for writing" << LL_ENDL;
  14.190 -		return;
  14.191 -	}
  14.192 -
  14.193 -	getCookieStore()->writePersistentCookies(file);
  14.194 -
  14.195 -	file.close();
  14.196 -}
  14.197 -
  14.198 -/////////////////////////////////////////////////////////////////////////////////////////
  14.199 -// static
  14.200 -void LLViewerMedia::addCookie(const std::string &name, const std::string &value, const std::string &domain, const LLDate &expires, const std::string &path, bool secure)
  14.201 -{
  14.202 -	std::stringstream cookie;
  14.203 -
  14.204 -	cookie << name << "=" << LLPluginCookieStore::quoteString(value);
  14.205 -
  14.206 -	if(expires.notNull())
  14.207 -	{
  14.208 -		cookie << "; expires=" << expires.asRFC1123();
  14.209 -	}
  14.210 -
  14.211 -	cookie << "; domain=" << domain;
  14.212 -
  14.213 -	cookie << "; path=" << path;
  14.214 -
  14.215 -	if(secure)
  14.216 -	{
  14.217 -		cookie << "; secure";
  14.218 -	}
  14.219 -
  14.220 -	getCookieStore()->setCookies(cookie.str());
  14.221 -}
  14.222 -
  14.223 -/////////////////////////////////////////////////////////////////////////////////////////
  14.224 -// static
  14.225 -void LLViewerMedia::addSessionCookie(const std::string &name, const std::string &value, const std::string &domain, const std::string &path, bool secure)
  14.226 -{
  14.227 -	// A session cookie just has a NULL date.
  14.228 -	addCookie(name, value, domain, LLDate(), path, secure);
  14.229 -}
  14.230 -
  14.231 -/////////////////////////////////////////////////////////////////////////////////////////
  14.232 -// static
  14.233 -void LLViewerMedia::removeCookie(const std::string &name, const std::string &domain, const std::string &path )
  14.234 -{
  14.235 -	// To remove a cookie, add one with the same name, domain, and path that expires in the past.
  14.236 -
  14.237 -	addCookie(name, "", domain, LLDate(LLDate::now().secondsSinceEpoch() - 1.0), path);
  14.238 -}
  14.239 -
  14.240 +//// static
  14.241  
  14.242  LLSD LLViewerMedia::getHeaders()
  14.243  {
  14.244 @@ -1384,8 +1196,6 @@
  14.245          hostEnd = authority.size();
  14.246      }
  14.247  
  14.248 -    getCookieStore()->setCookiesFromHost(sOpenIDCookie, authority.substr(hostStart, hostEnd - hostStart));
  14.249 -
  14.250  	if (url.length())
  14.251  	{
  14.252  		LLMediaCtrl* media_instance = LLFloaterReg::getInstance("destinations")->getChild<LLMediaCtrl>("destination_guide_contents");
  14.253 @@ -1423,7 +1233,6 @@
  14.254      httpHeaders->append(HTTP_OUT_HEADER_COOKIE, sOpenIDCookie);
  14.255      httpHeaders->append(HTTP_OUT_HEADER_USER_AGENT, getCurrentUserAgent());
  14.256  
  14.257 -
  14.258      LL_DEBUGS("MediaAuth") << "Requesting " << url << LL_ENDL;
  14.259      LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << LL_ENDL;
  14.260      
  14.261 @@ -1448,13 +1257,9 @@
  14.262      const std::string& cookie = resultHeaders[HTTP_IN_HEADER_SET_COOKIE].asStringRef();
  14.263      LL_DEBUGS("MediaAuth") << "cookie = " << cookie << LL_ENDL;
  14.264  
  14.265 -    // *TODO: What about bad status codes?  Does this destroy previous cookies?
  14.266 -    LLViewerMedia::getCookieStore()->setCookiesFromHost(cookie, hostAuth);
  14.267 -
  14.268      // Set cookie for snapshot publishing.
  14.269      std::string authCookie = cookie.substr(0, cookie.find(";")); // strip path
  14.270      LLWebProfile::setAuthCookie(authCookie);
  14.271 -
  14.272  }
  14.273  
  14.274  /////////////////////////////////////////////////////////////////////////////////////////
  14.275 @@ -1649,12 +1454,6 @@
  14.276  		delete sSpareBrowserMediaSource;
  14.277  		sSpareBrowserMediaSource = NULL;
  14.278  	}
  14.279 -
  14.280 -	if (sCookieStore != NULL)
  14.281 -	{
  14.282 -		delete sCookieStore;
  14.283 -		sCookieStore = NULL;
  14.284 -	}
  14.285  }
  14.286  
  14.287  //////////////////////////////////////////////////////////////////////////////////////////
  14.288 @@ -1922,7 +1721,7 @@
  14.289  
  14.290  			// collect 'cookies enabled' setting from prefs and send to embedded browser
  14.291  			bool cookies_enabled = gSavedSettings.getBOOL( "CookiesEnabled" );
  14.292 -			media_source->enable_cookies( cookies_enabled || clean_browser);
  14.293 +			media_source->cookies_enabled( cookies_enabled || clean_browser);
  14.294  
  14.295  			// collect 'plugins enabled' setting from prefs and send to embedded browser
  14.296  			bool plugins_enabled = gSavedSettings.getBOOL( "BrowserPluginsEnabled" );
  14.297 @@ -2031,17 +1830,6 @@
  14.298  			media_source->clear_cache();
  14.299  		}
  14.300  
  14.301 -		// TODO: Only send cookies to plugins that need them
  14.302 -		//  Ideally, the plugin should tell us whether it handles cookies or not -- either via the init response or through a separate message.
  14.303 -		//  Due to the ordering of messages, it's possible we wouldn't get that information back in time to send cookies before sending a navigate message,
  14.304 -		//  which could cause odd race conditions.
  14.305 -		std::string all_cookies = LLViewerMedia::getCookieStore()->getAllCookies();
  14.306 -		LL_DEBUGS() << "setting cookies: " << all_cookies << LL_ENDL;
  14.307 -		if(!all_cookies.empty())
  14.308 -		{
  14.309 -			media_source->set_cookies(all_cookies);
  14.310 -		}
  14.311 -
  14.312  		mMediaSource = media_source;
  14.313  		mMediaSource->setDeleteOK(false) ;
  14.314  		updateVolume();
  14.315 @@ -2983,14 +2771,10 @@
  14.316  		updateVolume();
  14.317  
  14.318  		// TODO: this is updated every frame - is this bad?
  14.319 -		updateJavascriptObject();
  14.320 -
  14.321 -		// If we didn't just create the impl, it may need to get cookie updates.
  14.322 -		if(!sUpdatedCookies.empty())
  14.323 -		{
  14.324 -			// TODO: Only send cookies to plugins that need them
  14.325 -			mMediaSource->set_cookies(sUpdatedCookies);
  14.326 -		}
  14.327 +		// Removing this as part of the post viewer64 media update
  14.328 +		// Removed as not implemented in CEF embedded browser
  14.329 +		// See MAINT-8194 for a more fuller description
  14.330 +		// updateJavascriptObject();
  14.331  	}
  14.332  
  14.333  
  14.334 @@ -3583,13 +3367,6 @@
  14.335  
  14.336  ////////////////////////////////////////////////////////////////////////////////
  14.337  // virtual
  14.338 -void LLViewerMediaImpl::handleCookieSet(LLPluginClassMedia* self, const std::string &cookie)
  14.339 -{
  14.340 -	LLViewerMedia::getCookieStore()->setCookies(cookie);
  14.341 -}
  14.342 -
  14.343 -////////////////////////////////////////////////////////////////////////////////
  14.344 -// virtual
  14.345  void
  14.346  LLViewerMediaImpl::cut()
  14.347  {
    15.1 --- a/indra/newview/llviewermedia.h	Thu Jan 11 10:32:23 2018 -0800
    15.2 +++ b/indra/newview/llviewermedia.h	Wed Jan 17 16:13:19 2018 -0800
    15.3 @@ -50,7 +50,6 @@
    15.4  class LLMediaEntry;
    15.5  class LLVOVolume;
    15.6  class LLMimeDiscoveryResponder;
    15.7 -class LLPluginCookieStore;
    15.8  
    15.9  typedef LLPointer<LLViewerMediaImpl> viewer_media_t;
   15.10  ///////////////////////////////////////////////////////////////////////////////
   15.11 @@ -149,13 +148,6 @@
   15.12  	// Set the proxy config for all loaded plugins
   15.13  	static void setProxyConfig(bool enable, const std::string &host, int port);
   15.14  	
   15.15 -	static LLPluginCookieStore *getCookieStore();
   15.16 -	static void loadCookieFile();
   15.17 -	static void saveCookieFile();
   15.18 -	static void addCookie(const std::string &name, const std::string &value, const std::string &domain, const LLDate &expires, const std::string &path = std::string("/"), bool secure = false );
   15.19 -	static void addSessionCookie(const std::string &name, const std::string &value, const std::string &domain, const std::string &path = std::string("/"), bool secure = false );
   15.20 -	static void removeCookie(const std::string &name, const std::string &domain, const std::string &path = std::string("/") );
   15.21 -
   15.22  	static void openIDSetup(const std::string &openid_url, const std::string &openid_token);
   15.23  	static void openIDCookieResponse(const std::string& url, const std::string &cookie);
   15.24  	
   15.25 @@ -178,7 +170,6 @@
   15.26      static void openIDSetupCoro(std::string openidUrl, std::string openidToken);
   15.27      static void getOpenIDCookieCoro(std::string url);
   15.28  
   15.29 -	static LLPluginCookieStore *sCookieStore;
   15.30  	static LLURL sOpenIDURL;
   15.31  	static std::string sOpenIDCookie;
   15.32  	static LLPluginClassMedia* sSpareBrowserMediaSource;
   15.33 @@ -337,7 +328,6 @@
   15.34  
   15.35  	// Inherited from LLPluginClassMediaOwner
   15.36  	/*virtual*/ void handleMediaEvent(LLPluginClassMedia* plugin, LLPluginClassMediaOwner::EMediaEvent);
   15.37 -	/*virtual*/ void handleCookieSet(LLPluginClassMedia* self, const std::string &cookie);
   15.38  
   15.39  	// LLEditMenuHandler overrides
   15.40  	/*virtual*/ void	cut();
    16.1 --- a/indra/newview/llwebprofile.cpp	Thu Jan 11 10:32:23 2018 -0800
    16.2 +++ b/indra/newview/llwebprofile.cpp	Wed Jan 17 16:13:19 2018 -0800
    16.3 @@ -31,7 +31,6 @@
    16.4  // libs
    16.5  #include "llbufferstream.h"
    16.6  #include "llimagepng.h"
    16.7 -#include "llplugincookiestore.h"
    16.8  
    16.9  #include "llsdserialize.h"
   16.10  

mercurial