changeset 1706:29fdac532dd0

- Escape URL before passing it from Java to Mozilla - Reduce delay on the "waiting for applet to initialize" message - Fix parser to handle "java:" in code attributes - rhbz# 487452 - Send stdout/stderr messages to console only in non-debug mode
author Deepak Bhole <dbhole@redhat.com>
date Thu, 26 Feb 2009 15:40:28 -0500
parents ecbd78fe74dc
children fd98e848b25c
files ChangeLog IcedTeaPlugin.cc plugin/icedtea/sun/applet/PluginAppletViewer.java plugin/icedtea/sun/applet/PluginMain.java
diffstat 4 files changed, 59 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Feb 26 14:12:08 2009 -0500
+++ b/ChangeLog	Thu Feb 26 15:40:28 2009 -0500
@@ -1,3 +1,12 @@
+2009-02-26  Deepak Bhole <dbhole@redhat.com>
+
+	* IcedTeaPlugin.cc: Decode url via nsINetUtil::UnescapeString()
+	* plugin/icedtea/sun/applet/PluginAppletViewer.java: Encode URL before
+	sending it to mozilla. Increment timeout for initialization message. Fix
+	parser to handle "java:" in code attribute.
+	* plugin/icedtea/sun/applet/PluginMain.java: Tee outputstream only if not
+	in debug mode.
+
 2009-02-26  Omair Majid  <omajid@redhat.com>
 
 	* patches/icedtea-xml-encodinginfo.patch: New file. Fix possible
--- a/IcedTeaPlugin.cc	Thu Feb 26 14:12:08 2009 -0500
+++ b/IcedTeaPlugin.cc	Thu Feb 26 15:40:28 2009 -0500
@@ -2885,6 +2885,7 @@
 }
 
 #include <nsServiceManagerUtils.h>
+#include <nsINetUtil.h>
 
 void
 IcedTeaPluginFactory::HandleMessage (nsCString const& message)
@@ -2968,7 +2969,17 @@
           if (instance != 0)
             {
               space = rest.FindChar (' ');
-              nsDependentCSubstring url = Substring (rest, 0, space);
+              nsDependentCSubstring escapedUrl = Substring (rest, 0, space);
+
+              nsresult rv;
+              nsCOMPtr<nsINetUtil> net_util = do_GetService(NS_NETUTIL_CONTRACTID, &rv);
+
+              if (!net_util)
+                printf("Error instantiating NetUtil service.\n");
+
+              nsDependentCSubstring url;
+              net_util->UnescapeString(escapedUrl, 0, url);
+
               nsDependentCSubstring target = Substring (rest, space + 1);
               nsCOMPtr<nsPIPluginInstancePeer> ownerGetter =
                 do_QueryInterface (instance->peer);
--- a/plugin/icedtea/sun/applet/PluginAppletViewer.java	Thu Feb 26 14:12:08 2009 -0500
+++ b/plugin/icedtea/sun/applet/PluginAppletViewer.java	Thu Feb 26 15:40:28 2009 -0500
@@ -99,6 +99,8 @@
 
 import javax.swing.SwingUtilities;
 
+import com.sun.jndi.toolkit.url.UrlUtil;
+
 import net.sourceforge.jnlp.NetxPanel;
 import net.sourceforge.jnlp.runtime.JNLPClassLoader;
 import sun.awt.AppContext;
@@ -309,7 +311,7 @@
  	Applet a;
     while ((a = panel.getApplet()) == null && panel.getAppletHandlerThread().isAlive()) {
    	 try {
-   		 Thread.sleep(100);
+   		 Thread.sleep(2000);
    		 PluginDebug.debug("Waiting for applet to initialize... ");
    	 } catch (InterruptedException ie) {
    		 ie.printStackTrace();
@@ -493,7 +495,7 @@
              // (happens in a separate thread)
              while ((o = panel.getApplet()) == null && panel.getAppletHandlerThread().isAlive()) {
             	 try {
-            		 Thread.sleep(100);
+            		 Thread.sleep(2000);
             		 PluginDebug.debug("Waiting for applet to initialize...");
             	 } catch (InterruptedException ie) {
             		 ie.printStackTrace();
@@ -765,7 +767,7 @@
      public void showDocument(URL url, String target) {
  	try {
              // FIXME: change to postCallRequest
- 	    write("url " + url + " " + target);
+ 	    write("url " + UrlUtil.encode(url.toString(), "UTF-8") + " " + target);
  	} catch (IOException exception) {
  	    // Deliberately ignore IOException.  showDocument may be
  	    // called from threads other than the main thread after
@@ -1606,12 +1608,15 @@
     					 isAppletTag = true;
     					 atts = scanTag(in);
 
-    					 // If there is a classid present, transform it to code tag
-    					 if (atts.get("code") == null && atts.get("classid") != null && 
-    							 ((String) atts.get("classid")).startsWith("java:")) {
-    						 //skip "java:"
-    						 atts.put("code", ((String) atts.get("classid")).substring(5));
-    					 }
+                         // If there is a classid and no code tag present, transform it to code tag
+                         if (atts.get("code") == null && atts.get("classid") != null) {
+                             atts.put("code", atts.get("classid"));
+                         }
+                         
+                         // remove java: from code tag
+                         if (atts.get("code") != null && ((String) atts.get("code")).startsWith("java:")) {
+                             atts.put("code", ((String) atts.get("code")).substring(5));
+                         }
 
     					 if (atts.get("code") == null && atts.get("object") == null) {
     						 statusMsgStream.println(appletRequiresCodeWarning);
@@ -1640,12 +1645,15 @@
     					 isObjectTag = true;
     					 atts = scanTag(in);
 
-    					 // If there is a classid present, transform it to code tag
-    					 if (atts.get("code") == null && atts.get("classid") != null && 
-    							 ((String) atts.get("classid")).startsWith("java:")) {
-    						 //skip "java:"
-    						 atts.put("code", ((String) atts.get("classid")).substring(5));
-    					 }
+    					 // If there is a classid and no code tag present, transform it to code tag
+                         if (atts.get("code") == null && atts.get("classid") != null) {
+                             atts.put("code", atts.get("classid"));
+                         }
+                         
+                         // remove java: from code tag
+                         if (atts.get("code") != null && ((String) atts.get("code")).startsWith("java:")) {
+                             atts.put("code", ((String) atts.get("code")).substring(5));
+                         }
 
                          // java_* aliases override older names:
                          // http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-ie
@@ -1698,12 +1706,15 @@
     					 isEmbedTag = true;
     					 atts = scanTag(in);
 
-    					 // If there is a classid present, transform it to code tag
-    					 if (atts.get("code") == null && atts.get("classid") != null && 
-    							 ((String) atts.get("classid")).startsWith("java:")) {
-    						 //skip "java:"
-    						 atts.put("code", ((String) atts.get("classid")).substring(5));
-    					 }
+                         // If there is a classid and no code tag present, transform it to code tag
+                         if (atts.get("code") == null && atts.get("classid") != null) {
+                             atts.put("code", atts.get("classid"));
+                         }
+                         
+                         // remove java: from code tag
+                         if (atts.get("code") != null && ((String) atts.get("code")).startsWith("java:")) {
+                             atts.put("code", ((String) atts.get("code")).substring(5));
+                         }
     					 
     					 // java_* aliases override older names:
     					 // http://java.sun.com/j2se/1.4.2/docs/guide/plugin/developer_guide/using_tags.html#in-nav
--- a/plugin/icedtea/sun/applet/PluginMain.java	Thu Feb 26 14:12:08 2009 -0500
+++ b/plugin/icedtea/sun/applet/PluginMain.java	Thu Feb 26 15:40:28 2009 -0500
@@ -270,13 +270,17 @@
         @Override
         public void write(int b) {
             logFile.write(b);
-            super.write(b);
+            
+            if (!redirectStreams)
+                super.write(b);
         }
 
         @Override
         public void write(byte[] b) throws IOException {
             logFile.write(b);
-            super.write(b);
+            
+            if (!redirectStreams)
+                super.write(b);
         }
     }