Sophie

Sophie

distrib > Mandriva > 2009.1 > x86_64 > by-pkgid > 5d9f96a61df66f474656cde507a94c17 > files > 18

java-1.6.0-openjdk-1.6.0.0-0.19.b14.3mdv2009.1.src.rpm

diff -Naur icedtea6-1.4.1/IcedTeaPlugin.cc icedtea6-1.4.1.tpg/IcedTeaPlugin.cc
--- icedtea6-1.4.1/IcedTeaPlugin.cc	2009-02-25 17:23:49.000000000 +0000
+++ icedtea6-1.4.1.tpg/IcedTeaPlugin.cc	2009-04-13 19:07:52.000000000 +0000
@@ -1063,6 +1063,7 @@
   IcedTeaPluginFactory* factory;
   PRUint32 instance_identifier;
   nsCString instanceIdentifierPrefix;
+  nsresult GetCookie(const char* siteAddr, char** cookieString);
 };
 
 
@@ -2281,6 +2282,12 @@
 
 }
 
+#include <nsICookieService.h>
+#include <nsIIOService.h>
+#include <nsIScriptSecurityManager.h>
+#include <nsIURI.h>
+#include <nsServiceManagerUtils.h>
+
 NS_IMPL_ISUPPORTS2 (IcedTeaPluginInstance, nsIPluginInstance,
                     nsIJVMPluginInstance)
 
@@ -2337,25 +2344,35 @@
   PLUGIN_DEBUG_1ARG("TAG FROM BROWSER = %s\n", tagMessage.get());
 
   // encode newline characters in the message
-  nsCString toSend("");
+  nsCString encodedAppletTag("");
   for (int i=0; i < tagMessage.Length(); i++)
   {
 	  if (tagMessage.get()[i] == '\r')
 	  {
-		  toSend += "&#13;";
+		  encodedAppletTag += "&#13;";
 		  continue;
 	  }
 
 	  if (tagMessage.get()[i] == '\n')
 	  {
-		  toSend += "&#10;";
+		  encodedAppletTag += "&#10;";
 		  continue;
 	  }
 
-	  toSend += tagMessage.get()[i];
+	  encodedAppletTag += tagMessage.get()[i];
   }
 
-  factory->SendMessageToAppletViewer (toSend);
+  nsCString cookieInfo(instanceIdentifierPrefix);
+  cookieInfo += "cookie ";
+
+  char* cookieString;
+  if (GetCookie(documentbase, &cookieString) == NS_OK)
+  {
+	  cookieInfo += cookieString;
+  }
+
+  factory->SendMessageToAppletViewer (cookieInfo);
+  factory->SendMessageToAppletViewer (encodedAppletTag);
 
   // Set back-pointer to peer instance.
   PLUGIN_DEBUG_1ARG ("SETTING PEER!!!: %p\n", aPeer);
@@ -2631,6 +2648,42 @@
 
 
 NS_IMETHODIMP
+IcedTeaPluginInstance::GetCookie(const char* siteAddr, char** cookieString) 
+{
+
+  nsresult rv;
+  nsCOMPtr<nsIScriptSecurityManager> sec_man = 
+    do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
+
+  if (!sec_man) {
+    return NS_ERROR_FAILURE;
+  }
+
+  nsCOMPtr<nsIIOService> io_svc = do_GetService(NS_IOSERVICE_CONTRACTID, &rv);
+
+  if (NS_FAILED(rv) || !io_svc) {
+    return NS_ERROR_FAILURE;
+  }
+
+  nsIURI *uri;
+  io_svc->NewURI(nsCString(siteAddr), NULL, NULL, &uri);
+
+  nsCOMPtr<nsICookieService> cookie_svc = do_GetService(NS_COOKIESERVICE_CONTRACTID, &rv);
+
+  if (NS_FAILED(rv) || !cookie_svc) {
+    return NS_ERROR_FAILURE;
+  }
+
+  rv = cookie_svc->GetCookieString(uri, NULL, cookieString);
+
+  if (NS_FAILED(rv) || !*cookieString) {
+    return NS_ERROR_FAILURE;
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 IcedTeaPluginFactory::GetJavaObject (PRUint32 instance_identifier,
                                      jobject* object)
 {
@@ -4438,10 +4491,7 @@
 #include <nsISocketTransport.h>
 #include <nsITransport.h>
 #include <nsNetCID.h>
-#include <nsServiceManagerUtils.h>
 #include <nsIPrincipal.h>
-#include <nsIScriptSecurityManager.h>
-#include <nsIURI.h>
 #include <xpcjsid.h>
 
 IcedTeaJNIEnv::IcedTeaJNIEnv (IcedTeaPluginFactory* factory)
@@ -4486,16 +4536,6 @@
 nsresult
 IcedTeaJNIEnv::GetEnabledPrivileges(nsCString *privileges, nsISecurityContext *ctx)
 {
-	nsresult rv;
-	nsCOMPtr<nsIScriptSecurityManager> sec_man = 
-		do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
-
-	if (NS_FAILED(rv) || !sec_man) {
-		return NS_ERROR_FAILURE;
-	}
-
-	PRBool isEnabled = PR_FALSE;
-
 	// check privileges one by one
 
 	privileges->Truncate();