From: SourceForge.net <no...@so...> - 2010-07-30 21:52:24
|
Bugs item #3022414, was opened at 2010-06-29 00:13 Message generated for change (Comment added) made by aditsu You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=113153&aid=3022414&group_id=13153 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: DOM Support Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) >Assigned to: Adrian Sandor (aditsu) Summary: getNodeValue() returning "value" for empty string Initial Comment: The fix for bug 2922337 made in revision 1094 looks to have introduced a problem parsing/retrieving empty string values. After parsing, the getNodeValue() method seems to return a value of "value" instead of empty string. For example, StringReader inReader = new StringReader(strHTML); Tidy tidy = new Tidy(); tidy.setShowWarnings(false); Document doc = tidy.parseDOM(inReader, null); Where strHTML contains... <input type="text" name="TEXT1" id="TEXT1" value="" maxlength="255" class="ltext" /> Using the getNodeValue() on the input node within the returned DOM returns "value" rather than "" node.getAttributes().getNamedItem("value").getNodeValue() Changing line 658 of the getString() function within TidyUtils.java to return an emptry string rather than null seems to prevent the problem: return length == 0 ? "" : new String(bytes, offset, Math.min(length, bytes.length - offset), "UTF8"); Seen in revision 1094 onwards. Revision 938 does not have this problem. ---------------------------------------------------------------------- >Comment By: Adrian Sandor (aditsu) Date: 2010-07-31 05:52 Message: The fix for bug 2922337 was actually the Math.min part; I added the "return null for empty" part for full compatibility with Tidy, but that seems to lose the distinction between empty attribute values and attributes with no value (for which the implicit value is the attribute name). I checked the "null for empty" change and it doesn't seem to affect anything else (except some messages in certain cases) so I changed it back now. Thanks for the report! ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=113153&aid=3022414&group_id=13153 |