JDK-4285874 : TTY: jdb chokes on command line arguments containing commas
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 1.3.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 1999-10-28
  • Updated: 2002-09-06
  • Resolved: 2002-09-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta2Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
The command line:

%jdb TestDriver nonvalidating all com.sun.xml.parser.Parser "Sun
Non-Validating Parser (latest, TR2)" conformance.xml
../../examples/samples/REC-xml-19980210.xml

generates:

Internal exception:  java.lang.IllegalArgumentException: Illegal
connector argument:  TR2)" conformance.xml
../../examples/samples/REC-xml-19980210.xml
        at
com.sun.tools.example.debug.tty.VMConnection.parseConnectorArgs(VMConnection.java:87)
        at
com.sun.tools.example.debug.tty.VMConnection.<init>(VMConnection.java:121)
        at com.sun.tools.example.debug.tty.Env.init(Env.java:59)
        at com.sun.tools.example.debug.tty.TTY.main(TTY.java:916

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta2 FIXED IN: merlin-beta2 INTEGRATED IN: merlin-beta2
14-06-2004

SUGGESTED FIX tim.bell@Eng 2001-04-25 Code review resulted in a better regex pattern. See below: tim.bell@Eng 2001-04-26 % sccs diffs -r1.35 VMConnection.java ------- VMConnection.java ------- 2c2 < * %W% %E% --- > * @(#)VMConnection.java 1.36 01/04/26 47a48 > import java.util.regex.*; 87d87 < StringTokenizer tokenizer = new StringTokenizer(argString, ","); 90,95c90,112 < while (tokenizer.hasMoreTokens()) { < String token = tokenizer.nextToken(); < int index = token.indexOf('='); < if (index == -1) { < throw new IllegalArgumentException("Illegal connector argument: " + < token); --- > /* > * We are parsing strings of the form: > * name1=value1,[name2=value2,...] > * However, the value1...valuen substrings may contain > * embedded comma(s), so make provision for quoting inside > * the value substrings. (Bug ID 4285874) > */ > String regexPattern = > "(quote=[^,]+,)|" + // special case for quote=., > "(\\w+=)" + // name= > "(((\"[^\"]*\")|" + // ( "l , ue" > "('[^']*')|" + // 'l , ue' > "([^,'\"]+))+,)"; // v a l u e )+ , > Pattern p = Pattern.compile(regexPattern); > Matcher m = p.matcher(argString); > while (m.find()) { > int startPosition = m.start(); > int endPosition = m.end(); > if (startPosition > 0) { > /* > * It is an error if parsing skips over any part of argString. > */ > throw new IllegalArgumentException("Illegal connector argument: " + argString); 96a114,116 > > String token = argString.substring(startPosition, endPosition); > int index = token.indexOf('='); 98c118,120 < String value = token.substring(index + 1); --- > String value = token.substring(index + 1, > token.length() - 1); // Remove comma delimiter > 105a128,130 > > argString = argString.substring(endPosition); // Remove what was just parsed... > m = p.matcher(argString); // and parse again on what is left. 106a132,137 > if (argString.length() > 0) { > /* > * It is an error if any part of argString is left over. > */ > throw new IllegalArgumentException("Illegal connector argument: " + argString); > }
11-06-2004

PUBLIC COMMENTS .
10-06-2004

EVALUATION The StringTokenizer used in VMConnection to parse connection specs does not take into consideration commas embedded in quoted strings. gordon.hirsch@eng 1999-10-28 The parse algorithm needs to deal with quoted strings correctly, probably using the same algorithm as the jdk1.3 Runtime.exec(String cmd) and Runtime.exec(String cmd, String[] envp) code. tim.bell@Eng 2000-11-14 Our job handling connection specs in jdb is not as simple as what is done in Runtime.exec(). We need to deal with argStrings like: <name1>[=<value1>],<name2>[=<value2>]... and also ignore delimiters in the debugee arguments at the tail end of the string. tim.bell@Eng 2001-04-19
19-04-2001