mx4j/src/core/javax/management ObjectName.java,1.22,1.23
Simone Bordet <[email protected]> Tue, 05 Oct 2004 13:17:54 +0000
| Newsgroups | gmane.comp.java.mx4j.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/mx4j/mx4j/src/core/javax/management
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27756/src/core/javax/management
Modified Files:
ObjectName.java
Log Message:
Fix for bug #1033067: ObjectName must discard quoted values that contains invalid escape sequences
Index: ObjectName.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/core/javax/management/ObjectName.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** ObjectName.java 4 Sep 2004 15:44:07 -0000 1.22
--- ObjectName.java 5 Oct 2004 13:17:51 -0000 1.23
***************
*** 584,587 ****
--- 584,600 ----
}
+ private int indexOfLastConsecutiveBackslash(String value, int from)
+ {
+ int index = value.indexOf('\\', from);
+ if (index < 0) return index;
+ if (index == value.length() - 1) return index;
+ // Probe next char
+ int next = indexOfLastConsecutiveBackslash(value, from + 1);
+ if (next < 0)
+ return index;
+ else
+ return next;
+ }
+
private boolean isValueValid(String value)
{
***************
*** 595,602 ****
--- 608,638 ----
value = value.substring(1, value.length() - 1);
+ // Be sure escaped values are interpreted correctly
int start = 0;
int index = -1;
do
{
+ index = indexOfLastConsecutiveBackslash(value, start);
+ if (index >= 0)
+ {
+ // Found a backslash sequence, see if it's an escape or a backslash
+ int count = countBackslashesBackwards(value, index + 1);
+ if (count % 2 != 0)
+ {
+ // Odd number of backslashes, probe next character, should be either '\', 'n', '"', '?', '*'
+ if (index == value.length() - 1) return false;
+
+ char next = value.charAt(index + 1);
+ if (next != '\\' && next != 'n' && next != '"' && next != '?' && next != '*') return false;
+ }
+ start = index + 1;
+ }
+ }
+ while (index >= 0);
+
+ start = 0;
+ index = -1;
+ do
+ {
index = value.indexOf('"', start);
if (index < 0) index = value.indexOf('*', start);
***************
*** 605,608 ****
--- 641,645 ----
{
int bslashCount = countBackslashesBackwards(value, index);
+ // There is a special character not preceded by an odd number of backslashes
if (bslashCount % 2 == 0) return false;
start = index + 1;
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl