Mercurial > hg > release > icedtea-web-1.2
changeset 267:6bfd819570c1
PR749: sun.applet.PluginStreamHandler#handleMessage(String) really slow
Original patch from: Ricardo Mart?n Camarero <rickyepoderi at yahoo dot es>
author | Deepak Bhole <dbhole@redhat.com> |
---|---|
date | Thu, 21 Jul 2011 15:11:38 -0400 |
parents | 7dd63058c234 |
children | 35f3c783e997 |
files | AUTHORS ChangeLog NEWS plugin/icedteanp/java/sun/applet/PluginStreamHandler.java |
diffstat | 4 files changed, 71 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/AUTHORS Fri Jul 15 16:02:00 2011 -0400 +++ b/AUTHORS Thu Jul 21 15:11:38 2011 -0400 @@ -3,6 +3,7 @@ Lillian Angel <langel@redhat.com> Deepak Bhole <dbhole@redhat.com> +Ricardo Martín Camarero <rickyepoderi@yahoo.es> Thomas Fitzsimmons <fitzsim@redhat.com> Mark Greenwood <mark@dcs.shef.ac.uk> Andrew John Hughes <gnu_andrew@member.fsf.org, ahughes@redhat.com>
--- a/ChangeLog Fri Jul 15 16:02:00 2011 -0400 +++ b/ChangeLog Thu Jul 21 15:11:38 2011 -0400 @@ -1,3 +1,12 @@ +2011-07-21 Deepak Bhole <dbhole@redhat.com> + + PR749: sun.applet.PluginStreamHandler#handleMessage(String) really slow + Original patch from: Ricardo Martín Camarero <rickyepoderi at yahoo dot es> + * plugin/icedteanp/java/sun/applet/PluginStreamHandler.java + (readPair): New function. + (handleMessage): Use readPair to incrementally tokenize message, rather + than using String.split(). + 2011-07-19 Saad Mohammad <smohammad@redhat.com> * netx/net/sourceforge/jnlp/JNLPMatcher.java:
--- a/NEWS Fri Jul 15 16:02:00 2011 -0400 +++ b/NEWS Thu Jul 21 15:11:38 2011 -0400 @@ -12,6 +12,8 @@ * Security updates: - RH718164, CVE-2011-2513: Home directory path disclosure to untrusted applications - RH718170, CVE-2011-2514: Java Web Start security warning dialog manipulation +* Plugin + - PR749: sun.applet.PluginStreamHandler#handleMessage(String) really slow New in release 1.1 (2011-XX-XX): * Security updates
--- a/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java Fri Jul 15 16:02:00 2011 -0400 +++ b/plugin/icedteanp/java/sun/applet/PluginStreamHandler.java Thu Jul 21 15:11:38 2011 -0400 @@ -113,18 +113,58 @@ listenerThread.start(); } + /** + * Given a string, reads the first two (space separated) tokens. + * + * @param message The string to read + * @param start The position to start reading at + * @param array The array into which the first two tokens are placed + * @return Position where the next token starts + */ + private int readPair(String message, int start, String[] array) { + + int end = start; + array[0] = null; + array[1] = null; + + if (message.length() > start) { + int firstSpace = message.indexOf(' ', start); + if (firstSpace == -1) { + array[0] = message.substring(start); + end = message.length(); + } else { + array[0] = message.substring(start, firstSpace); + if (message.length() > firstSpace + 1) { + int secondSpace = message.indexOf(' ', firstSpace + 1); + if (secondSpace == -1) { + array[1] = message.substring(firstSpace + 1); + end = message.length(); + } else { + array[1] = message.substring(firstSpace + 1, secondSpace); + end = secondSpace + 1; + } + } + } + } + + PluginDebug.debug("readPair: '", array[0], "' - '", array[1], "' ", end); + return end; + } + public void handleMessage(String message) throws PluginException { - int nextIndex = 0; int reference = -1; String src = null; String[] privileges = null; String rest = ""; - - String[] msgComponents = message.split(" "); + String[] msgComponents = new String[2]; + int pos = 0; + int oldPos = 0; - if (msgComponents.length < 2) + pos = readPair(message, oldPos, msgComponents); + if (msgComponents[0] == null || msgComponents[1] == null) { return; + } if (msgComponents[0].startsWith("plugin")) { handlePluginMessage(message); @@ -134,38 +174,38 @@ // type and identifier are guaranteed to be there String type = msgComponents[0]; final int identifier = Integer.parseInt(msgComponents[1]); - nextIndex = 2; // reference, src and privileges are optional components, // and are guaranteed to be in that order, if they occur + oldPos = pos; + pos = readPair(message, oldPos, msgComponents); // is there a reference ? - if (msgComponents[nextIndex].equals("reference")) { - reference = Integer.parseInt(msgComponents[nextIndex + 1]); - nextIndex += 2; + if ("reference".equals(msgComponents[0])) { + reference = Integer.parseInt(msgComponents[1]); + oldPos = pos; + pos = readPair(message, oldPos, msgComponents); } // is there a src? - if (msgComponents[nextIndex].equals("src")) { - src = msgComponents[nextIndex + 1]; - nextIndex += 2; + if ("src".equals(msgComponents[0])) { + src = msgComponents[1]; + oldPos = pos; + pos = readPair(message, oldPos, msgComponents); } // is there a privileges? - if (msgComponents[nextIndex].equals("privileges")) { - String privs = msgComponents[nextIndex + 1]; + if ("privileges".equals(msgComponents[0])) { + String privs = msgComponents[1]; privileges = privs.split(","); - nextIndex += 2; + oldPos = pos; } // rest - for (int i = nextIndex; i < msgComponents.length; i++) { - rest += msgComponents[i]; - rest += " "; + if (message.length() > oldPos) { + rest = message.substring(oldPos); } - rest = rest.trim(); - try { PluginDebug.debug("Breakdown -- type: ", type, " identifier: ", identifier, " reference: ", reference, " src: ", src, " privileges: ", privileges, " rest: \"", rest, "\"");