From: Igor A. <ig...@us...> - 2004-08-18 21:48:28
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18591/src/org/exist/dom Modified Files: ElementImpl.java Log Message: Fix to toString(boolean, TreeSet), to properly escape XML characters. Values were decoded (for instance, ">" were decoded to ">") upon attribute's creation, but weren't re-encoded upon serialization by toString. Added a method escapeXml (as I couldn't find another implementation. If there is any, I'll be glad to reuse). Index: ElementImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ElementImpl.java,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** ElementImpl.java 9 Aug 2004 10:24:31 -0000 1.45 --- ElementImpl.java 18 Aug 2004 21:48:19 -0000 1.46 *************** *** 24,39 **** package org.exist.dom; - import java.io.ByteArrayInputStream; - import java.io.ByteArrayOutputStream; - import java.io.DataInputStream; - import java.io.DataOutputStream; - import java.io.IOException; - import java.util.ArrayList; - import java.util.HashMap; - import java.util.Iterator; [...2543 lines suppressed...] + break; + } + if (buffer == null) { + if (entity != null) { + buffer = new StringBuffer(str.length() + 20); + buffer.append(str.substring(0, i)); + buffer.append(entity); + } + } + else { + if (entity == null) + buffer.append(ch); + else + buffer.append(entity); + } + } + + return (buffer == null) ? str : buffer.toString(); + } } |