changeset in /hg/icedtea6: - Escape URL before passing it from J...

Deepak Bhole dbhole at redhat.com
Thu Feb 26 12:40:33 PST 2009


changeset 29fdac532dd0 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=29fdac532dd0
description:
	- 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

diffstat:

4 files changed, 59 insertions(+), 24 deletions(-)
ChangeLog                                         |    9 +++
IcedTeaPlugin.cc                                  |   13 ++++-
plugin/icedtea/sun/applet/PluginAppletViewer.java |   53 ++++++++++++---------
plugin/icedtea/sun/applet/PluginMain.java         |    8 ++-

diffs (174 lines):

diff -r ecbd78fe74dc -r 29fdac532dd0 ChangeLog
--- 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  Omair Majid  <omajid at redhat.
+2009-02-26  Deepak Bhole <dbhole at 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 at redhat.com>
 
 	* patches/icedtea-xml-encodinginfo.patch: New file. Fix possible
diff -r ecbd78fe74dc -r 29fdac532dd0 IcedTeaPlugin.cc
--- 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 @@ IcedTeaPluginFactory::OnInputStreamReady
 }
 
 #include <nsServiceManagerUtils.h>
+#include <nsINetUtil.h>
 
 void
 IcedTeaPluginFactory::HandleMessage (nsCString const& message)
@@ -2968,7 +2969,17 @@ IcedTeaPluginFactory::HandleMessage (nsC
           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);
diff -r ecbd78fe74dc -r 29fdac532dd0 plugin/icedtea/sun/applet/PluginAppletViewer.java
--- 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 java.util.Vector;
 
 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 @@ import sun.misc.Ref;
  	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 @@ import sun.misc.Ref;
              // (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 @@ import sun.misc.Ref;
      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 @@ import sun.misc.Ref;
     					 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 @@ import sun.misc.Ref;
     					 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 @@ import sun.misc.Ref;
     					 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
diff -r ecbd78fe74dc -r 29fdac532dd0 plugin/icedtea/sun/applet/PluginMain.java
--- 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 @@ public class PluginMain
         @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);
         }
     }
     



More information about the distro-pkg-dev mailing list