From 9c43b62fdfe9350b357fc0eae7078992f7e6c00b Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 11 Apr 2007 10:33:39 +0000 Subject: 2007-04-09 Andrew John Hughes * javax/management/ObjectName.java: (parse(String)): Catch multiple wildcards, initialise with an empty string (so null isn't appended), and emit comma even when wildcard ends the list. (checkComponents()): Catch newlines. (quote(String)): Handle newlines and quotes correctly. --- ChangeLog | 11 +++++++++++ javax/management/ObjectName.java | 22 +++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 89fa0174f..53c2332c4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-04-09 Andrew John Hughes + + * javax/management/ObjectName.java: + (parse(String)): Catch multiple wildcards, + initialise with an empty string (so null isn't + appended), and emit comma even when wildcard + ends the list. + (checkComponents()): Catch newlines. + (quote(String)): Handle newlines and quotes + correctly. + 2007-04-10 Mark Wielaard * native/jni/gtk-peer/gnu_java_awt_peer_gtk_ComponentGraphics.c diff --git a/javax/management/ObjectName.java b/javax/management/ObjectName.java index d9586eefe..a3f30efff 100644 --- a/javax/management/ObjectName.java +++ b/javax/management/ObjectName.java @@ -197,10 +197,14 @@ public class ObjectName throw new MalformedObjectNameException("A name that is not a " + "pattern must contain at " + "least one key-value pair."); + propertyListString = ""; for (int a = 0; a < pairs.length; ++a) { if (pairs[a].equals("*")) { + if (propertyPattern) + throw new MalformedObjectNameException("Multiple wildcards " + + "in properties."); propertyPattern = true; continue; } @@ -214,10 +218,11 @@ public class ObjectName "more than once."); String value = pairs[a].substring(sep+1); properties.put(key, value); - propertyListString += key + "=" + value; - if (a != (pairs.length - 1)) - propertyListString += ","; + propertyListString += key + "=" + value + ","; } + if (propertyListString.length() > 0) + propertyListString = + propertyListString.substring(0, propertyListString.length() - 1); checkComponents(); } @@ -286,7 +291,7 @@ public class ObjectName if (domain.indexOf('\n') != -1) throw new MalformedObjectNameException("The domain includes a newline " + "character."); - char[] chars = new char[] { ':', ',', '*', '?', '=' }; + char[] chars = new char[] { '\n', ':', ',', '*', '?', '=' }; Iterator i = properties.entrySet().iterator(); while (i.hasNext()) { @@ -307,8 +312,9 @@ public class ObjectName } catch (IllegalArgumentException e) { - throw new MalformedObjectNameException("The quoted value is " + - "invalid."); + throw (MalformedObjectNameException) + new MalformedObjectNameException("The quoted value is " + + "invalid.").initCause(e); } } else if (quote != -1) @@ -865,10 +871,12 @@ public class ObjectName { n = q.charAt(++a); if (n != '"' && n != '?' && n != '*' && - n != '\n' && n != '\\') + n != 'n' && n != '\\') throw new IllegalArgumentException("Illegal escaped character: " + n); } + else if (n == '"' || n == '\n') + throw new IllegalArgumentException("Illegal character: " + n); builder.append(n); } -- cgit v1.2.1