diff options
author | Mark Wielaard <mark@klomp.org> | 2007-04-11 10:33:39 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2007-04-11 10:33:39 +0000 |
commit | 9c43b62fdfe9350b357fc0eae7078992f7e6c00b (patch) | |
tree | 364f02cb41de15b65170620232c39064f07723c4 | |
parent | e335597005abd68253efb98cce1bbf69f12c6a70 (diff) | |
download | classpath-9c43b62fdfe9350b357fc0eae7078992f7e6c00b.tar.gz |
2007-04-09 Andrew John Hughes <gnu_andrew@member.fsf.org>
* 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.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | javax/management/ObjectName.java | 22 |
2 files changed, 26 insertions, 7 deletions
@@ -1,3 +1,14 @@ +2007-04-09 Andrew John Hughes <gnu_andrew@member.fsf.org> + + * 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 <mark@klomp.org> * 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); } |