[jdom-interest] Bug in parseData(String rawData) in ProcessingInstruction.java

Albert Chang - 張拓 albert_chang at tnce.com.tw
Tue Apr 16 03:32:32 PDT 2002

Dear all:

	<?pi href =  ”http://www.jdom.org”  media = “wap”?> <!-- Please note
the spaces inserted between the equal, ‘=’, signs.-->
won’t be parsed properly if you set data via the following code snippet.
ProcessingInstruction pi(“pi”, “href =   \”http://www.jdom.org\”  media =
// Please note the spaces inserted between the equal, ‘=’, signs.

	After hacking into the source, org.jdom.ProcessingInstuction.java,
it failed on the privte function:
private Map paresData(String rawData), while parsing the media attribute.
	The suspicious code is “pos += value.lenth() + 1;” in code sinppet
       if (currentChar == '=') {
                    name = inputData.substring(startName, pos).trim();
                    value =
                    // A null value means a parse error and we return empty!
                    if (value == null) {
                        return new HashMap();
                    pos += value.length() + 1;  // skip over equals and
⇨ Since there are extra spaces between ‘=’ sign for the first “href”
attribute, we shouldn’t just naiively use pos += value.length() + 1 to skip
over value. This will not move to the media attribute, but rather between
the value of href.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020416/7634b1f7/attachment.htm

More information about the jdom-interest mailing list