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

=?big5?B?QWxiZXJ0IENoYW5nIC0gsWmp3Q==?= albert_chang at tnce.com.tw
Mon Apr 15 00:03:52 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
=  \¡§wap\¡¨¡¨); 
// 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 below:
          ¡K.
  if (currentChar == '=') {
                    name = inputData.substring(startName, pos).trim();
                    value =
extractQuotedString(inputData.substring(pos+1).trim());
                    // 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
value
                    break;
                }
          ¡K¡K
*     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.
 
Regards,
Albert
 
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jdom.org/pipermail/jdom-interest/attachments/20020415/541ec3f7/attachment.htm


More information about the jdom-interest mailing list