From e9689c098bd56cffb72820a511e41e89c96ce0eb Mon Sep 17 00:00:00 2001 From: Deepak Bhole Date: Wed, 8 Dec 2010 16:08:35 -0500 Subject: PR597: Fix special character handling for applet tags --- .../java/sun/applet/PluginAppletViewer.java | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'plugin/icedteanp/java/sun/applet/PluginAppletViewer.java') diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java index f895361..2b9b0c3 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java @@ -514,14 +514,6 @@ public class PluginAppletViewer extends XEmbeddedFrame UrlUtil.decode(message.substring("tag".length() + 1, spaceLocation)); String tag = message.substring(spaceLocation + 1); - // Decode the tag - tag = tag.replace(">", ">"); - tag = tag.replace("<", "<"); - tag = tag.replace("&", "&"); - tag = tag.replace(" ", "\n"); - tag = tag.replace(" ", "\r"); - tag = tag.replace(""", "\""); - PluginDebug.debug("Handle = " + handle + "\n" + "Width = " + width + "\n" + "Height = " + height + "\n" + @@ -1453,6 +1445,24 @@ public class PluginAppletViewer extends XEmbeddedFrame return null; } + /** + * Decodes the string (converts html escapes into proper characters) + * + * @param toDecode The string to decode + * @return The decoded string + */ + public static String decodeString(String toDecode) { + + toDecode = toDecode.replace(">", ">"); + toDecode = toDecode.replace("<", "<"); + toDecode = toDecode.replace("&", "&"); + toDecode = toDecode.replace(" ", "\n"); + toDecode = toDecode.replace(" ", "\r"); + toDecode = toDecode.replace(""", "\""); + + return toDecode; + } + /** * System parameters. */ @@ -1752,7 +1762,7 @@ public class PluginAppletViewer extends XEmbeddedFrame Hashtable atts = new Hashtable(); skipSpace(c, in); while (c[0] >= 0 && c[0] != '>') { - String att = scanIdentifier(c, in); + String att = decodeString(scanIdentifier(c, in)); String val = ""; skipSpace(c, in); if (c[0] == '=') { @@ -1775,7 +1785,7 @@ public class PluginAppletViewer extends XEmbeddedFrame c[0] = in.read(); } skipSpace(c, in); - val = buf.toString(); + val = decodeString(buf.toString()); } PluginDebug.debug("PUT " + att + " = '" + val + "'"); -- cgit v1.2.3