Mon, 20 Apr 2009 15:25:02 -0700
Merge
make/jprt.config | file | annotate | diff | comparison | revisions | |
src/share/classes/com/sun/xml/internal/bind/v2/runtime/output/UTF8XmlOutput.java | file | annotate | diff | comparison | revisions |
1.1 --- a/.hgtags Mon Apr 20 15:14:39 2009 -0700 1.2 +++ b/.hgtags Mon Apr 20 15:25:02 2009 -0700 1.3 @@ -25,3 +25,8 @@ 1.4 01e5dd31d0c10a2db3d50db346905d2d3db45e88 jdk7-b48 1.5 18ca864890f3d4ed942ecbffb78c936a57759921 jdk7-b49 1.6 5be52db581f1ea91ab6e0eb34ba7f439125bfb16 jdk7-b50 1.7 +41a66a42791ba90bff489af72cbfea71be9b40a5 jdk7-b51 1.8 +e646890d18b770f625f14ed4ad5c50554d8d3d8b jdk7-b52 1.9 +b250218eb2e534384667ec73e3713e684667fd4c jdk7-b53 1.10 +50ea00dc5f143fe00025233e704903c37f8464aa jdk7-b54 1.11 +e0eebd978b830c09e7862cff3f77a914c15651c9 jdk7-b55
2.1 --- a/make/jprt.config Mon Apr 20 15:14:39 2009 -0700 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,241 +0,0 @@ 2.4 -#!echo "This is not a shell script" 2.5 -############################################################################# 2.6 -# 2.7 -# Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. 2.8 -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.9 -# 2.10 -# This code is free software; you can redistribute it and/or modify it 2.11 -# under the terms of the GNU General Public License version 2 only, as 2.12 -# published by the Free Software Foundation. Sun designates this 2.13 -# particular file as subject to the "Classpath" exception as provided 2.14 -# by Sun in the LICENSE file that accompanied this code. 2.15 -# 2.16 -# This code is distributed in the hope that it will be useful, but WITHOUT 2.17 -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.18 -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.19 -# version 2 for more details (a copy is included in the LICENSE file that 2.20 -# accompanied this code). 2.21 -# 2.22 -# You should have received a copy of the GNU General Public License version 2.23 -# 2 along with this work; if not, write to the Free Software Foundation, 2.24 -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.25 -# 2.26 -# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 2.27 -# CA 95054 USA or visit www.sun.com if you need additional information or 2.28 -# have any questions. 2.29 -# 2.30 -############################################################################# 2.31 -# 2.32 -# JPRT shell configuration for building. 2.33 -# 2.34 -# Input environment variables: 2.35 -# ALT_BOOTDIR 2.36 -# ALT_SLASH_JAVA 2.37 -# ALT_JDK_IMPORT_PATH 2.38 -# Windows Only: 2.39 -# PATH 2.40 -# PROCESSOR_IDENTIFIER 2.41 -# ROOTDIR 2.42 -# 2.43 -# Output variable settings: 2.44 -# make Full path to GNU make 2.45 -# 2.46 -# Output environment variables: 2.47 -# PATH 2.48 -# Windows Only: 2.49 -# ALT_DEVTOOLS_PATH (To avoid the C:/UTILS default) 2.50 -# 2.51 -# After JDK6, most settings will be found via ALT_SLASH_JAVA or 2.52 -# by way of other system environment variables. If this was JDK5 2.53 -# or an older JDK, you might need to export more ALT_* variables. 2.54 -# 2.55 -############################################################################# 2.56 - 2.57 -############################################################################# 2.58 -# Error 2.59 -error() # message 2.60 -{ 2.61 - echo "ERROR: $1" 2.62 - exit 6 2.63 -} 2.64 -# Directory must exist 2.65 -dirMustExist() # dir name 2.66 -{ 2.67 - if [ ! -d "$1" ] ; then 2.68 - error "Directory for $2 does not exist: $1" 2.69 - fi 2.70 -} 2.71 -# File must exist 2.72 -fileMustExist() # dir name 2.73 -{ 2.74 - if [ ! -f "$1" ] ; then 2.75 - error "File for $2 does not exist: $1" 2.76 - fi 2.77 -} 2.78 -############################################################################# 2.79 - 2.80 -# Should be set by JPRT as the 3 basic inputs 2.81 -bootdir="${ALT_BOOTDIR}" 2.82 -slashjava="${ALT_SLASH_JAVA}" 2.83 -jdk_import="${ALT_JDK_IMPORT_PATH}" 2.84 - 2.85 -# Check input 2.86 -dirMustExist "${bootdir}" ALT_BOOTDIR 2.87 -dirMustExist "${slashjava}" ALT_SLASH_JAVA 2.88 -dirMustExist "${jdk_import}" ALT_JDK_IMPORT_PATH 2.89 - 2.90 -# Uses 'uname -s', but only expect SunOS or Linux, assume Windows otherwise. 2.91 -osname=`uname -s` 2.92 -if [ "${osname}" = SunOS ] ; then 2.93 - 2.94 - # SOLARIS: Sparc or X86 2.95 - osarch=`uname -p` 2.96 - if [ "${osarch}" = sparc ] ; then 2.97 - solaris_arch=sparc 2.98 - else 2.99 - solaris_arch=i386 2.100 - fi 2.101 - 2.102 - # Add basic solaris system paths 2.103 - path4sdk=/usr/ccs/bin:/usr/ccs/lib:/usr/bin:/bin:/usr/sfw/bin 2.104 - 2.105 - # Get the previous JDK to be used to bootstrap the build 2.106 - path4sdk=${bootdir}/bin:${path4sdk} 2.107 - 2.108 - # Ant 2.109 - ANT_HOME=${slashjava}/devtools/share/ant/1.7.0 2.110 - export ANT_HOME 2.111 - antbindir=${ANT_HOME}/bin 2.112 - fileMustExist "${antbindir}/ant" ant 2.113 - path4sdk=${antbindir}:${path4sdk} 2.114 - 2.115 - # Find GNU make 2.116 - make=/usr/sfw/bin/gmake 2.117 - if [ ! -f ${make} ] ; then 2.118 - make=/opt/sfw/bin/gmake 2.119 - if [ ! -f ${make} ] ; then 2.120 - make=${slashjava}/devtools/${solaris_arch}/bin/gnumake 2.121 - fi 2.122 - fi 2.123 - fileMustExist "${make}" make 2.124 - 2.125 - # File creation mask 2.126 - umask 002 2.127 - 2.128 -elif [ "${osname}" = Linux ] ; then 2.129 - 2.130 - # LINUX: X86, AMD64 2.131 - osarch=`uname -m` 2.132 - if [ "${osarch}" = i686 ] ; then 2.133 - linux_arch=i586 2.134 - elif [ "${osarch}" = x86_64 ] ; then 2.135 - linux_arch=amd64 2.136 - fi 2.137 - 2.138 - # Add basic paths 2.139 - path4sdk=/usr/bin:/bin:/usr/sbin:/sbin 2.140 - 2.141 - # Get the previous JDK to be used to bootstrap the build 2.142 - path4sdk=${bootdir}/bin:${path4sdk} 2.143 - 2.144 - # Ant 2.145 - ANT_HOME=${slashjava}/devtools/share/ant/1.7.0 2.146 - export ANT_HOME 2.147 - antbindir=${ANT_HOME}/bin 2.148 - fileMustExist "${antbindir}/ant" ant 2.149 - path4sdk=${antbindir}:${path4sdk} 2.150 - 2.151 - # Find GNU make 2.152 - make=/usr/bin/make 2.153 - fileMustExist "${make}" make 2.154 - 2.155 - umask 002 2.156 - 2.157 -else 2.158 - 2.159 - # Windows: Differs on CYGWIN vs. MKS. 2.160 - # Also, blanks in pathnames gives GNU make headaches, so anything placed 2.161 - # in any ALT_* variable should be the short windows dosname. 2.162 - 2.163 - # WINDOWS: Install and use MKS or CYGWIN (should have already been done) 2.164 - # Assumption here is that you are in a shell window via MKS or cygwin. 2.165 - # MKS install should have defined the environment variable ROOTDIR. 2.166 - # We also need to figure out which one we have: X86, AMD64 2.167 - if [ "`echo ${PROCESSOR_IDENTIFIER} | fgrep AMD64`" != "" ] ; then 2.168 - windows_arch=amd64 2.169 - else 2.170 - windows_arch=i586 2.171 - fi 2.172 - 2.173 - # We need to determine if we are running a CYGWIN shell or an MKS shell 2.174 - # (if uname isn't available, then it will be unix_toolset=unknown) 2.175 - unix_toolset=unknown 2.176 - if [ "`uname -a | fgrep Cygwin`" = "" -a -d "${ROOTDIR}" ] ; then 2.177 - # We kind of assume ROOTDIR is where MKS is and it's ok 2.178 - unix_toolset=MKS 2.179 - mkshome=`dosname -s "${ROOTDIR}"` 2.180 - # Utility to convert to short pathnames without spaces 2.181 - dosname="${mkshome}/mksnt/dosname -s" 2.182 - # Most unix utilities are in the mksnt directory of ROOTDIR 2.183 - unixcommand_path="${mkshome}/mksnt" 2.184 - path4sdk="${unixcommand_path}" 2.185 - dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH 2.186 - devtools_path="${slashjava}/devtools/win32/bin" 2.187 - path4sdk="${devtools_path};${path4sdk}" 2.188 - # Normally this need not be set, but on Windows it's default is C:/UTILS 2.189 - ALT_DEVTOOLS_PATH="${devtools_path}" 2.190 - export ALT_DEVTOOLS_PATH 2.191 - dirMustExist "${devtools_path}" ALT_DEVTOOLS_PATH 2.192 - # Find GNU make 2.193 - make="${devtools_path}/gnumake.exe" 2.194 - fileMustExist "${make}" make 2.195 - elif [ "`uname -a | fgrep Cygwin`" != "" -a -f /bin/cygpath ] ; then 2.196 - # For CYGWIN, uname will have "Cygwin" in it, and /bin/cygpath should exist 2.197 - unix_toolset=CYGWIN 2.198 - # Utility to convert to short pathnames without spaces 2.199 - dosname="/usr/bin/cygpath -a -m -s" 2.200 - # Most unix utilities are in the /usr/bin 2.201 - unixcommand_path="/usr/bin" 2.202 - path4sdk="${unixcommand_path}" 2.203 - dirMustExist "${unixcommand_path}" ALT_UNIXCOMMAND_PATH 2.204 - # Find GNU make 2.205 - make="${unixcommand_path}/make.exe" 2.206 - fileMustExist "${make}" make 2.207 - else 2.208 - echo "WARNING: Cannot figure out if this is MKS or CYGWIN" 2.209 - fi 2.210 - 2.211 - # WINDOWS: Get the previous JDK to be used to bootstrap the build 2.212 - path4sdk="${bootdir}/bin;${path4sdk}" 2.213 - 2.214 - # Ant 2.215 - ANT_HOME=${slashjava}/devtools/share/ant/1.7.0 2.216 - export ANT_HOME 2.217 - antbindir=${ANT_HOME}/bin 2.218 - fileMustExist "${antbindir}/ant" ant 2.219 - path4sdk="${antbindir};${path4sdk}" 2.220 - 2.221 - # Turn all \\ into /, remove duplicates and trailing / 2.222 - slash_path="`echo ${path4sdk} | sed -e 's@\\\\@/@g' -e 's@//@/@g' -e 's@/$@@' -e 's@/;@;@g'`" 2.223 - 2.224 - # For windows, it's hard to know where the system is, so we just add this 2.225 - # to PATH. 2.226 - path4sdk="${slash_path};${PATH}" 2.227 - 2.228 - # Convert path4sdk to cygwin style 2.229 - if [ "${unix_toolset}" = CYGWIN ] ; then 2.230 - path4sdk="`/usr/bin/cygpath -p ${path4sdk}`" 2.231 - fi 2.232 - 2.233 -fi 2.234 - 2.235 -# Export PATH setting 2.236 -PATH="${path4sdk}" 2.237 -export PATH 2.238 - 2.239 -# Things we need to unset 2.240 -unset LD_LIBRARY_PATH 2.241 -unset LD_LIBRARY_PATH_32 2.242 -unset LD_LIBRARY_PATH_64 2.243 -unset JAVA_HOME 2.244 -
3.1 --- a/src/share/classes/com/sun/xml/internal/bind/v2/runtime/output/UTF8XmlOutput.java Mon Apr 20 15:14:39 2009 -0700 3.2 +++ b/src/share/classes/com/sun/xml/internal/bind/v2/runtime/output/UTF8XmlOutput.java Mon Apr 20 15:25:02 2009 -0700 3.3 @@ -32,6 +32,7 @@ 3.4 import com.sun.xml.internal.bind.DatatypeConverterImpl; 3.5 import com.sun.xml.internal.bind.v2.runtime.Name; 3.6 import com.sun.xml.internal.bind.v2.runtime.XMLSerializer; 3.7 +import com.sun.xml.internal.bind.v2.runtime.MarshallerImpl; 3.8 3.9 import org.xml.sax.SAXException; 3.10 3.11 @@ -81,6 +82,11 @@ 3.12 protected boolean closeStartTagPending = false; 3.13 3.14 /** 3.15 + * @see MarshallerImpl#header 3.16 + */ 3.17 + private String header; 3.18 + 3.19 + /** 3.20 * 3.21 * @param localNames 3.22 * local names encoded in UTF-8. 3.23 @@ -92,6 +98,10 @@ 3.24 prefixes[i] = new Encoded(); 3.25 } 3.26 3.27 + public void setHeader(String header) { 3.28 + this.header = header; 3.29 + } 3.30 + 3.31 @Override 3.32 public void startDocument(XMLSerializer serializer, boolean fragment, int[] nsUriIndex2prefixIndex, NamespaceContextImpl nsContext) throws IOException, SAXException, XMLStreamException { 3.33 super.startDocument(serializer, fragment,nsUriIndex2prefixIndex,nsContext); 3.34 @@ -100,6 +110,10 @@ 3.35 if(!fragment) { 3.36 write(XML_DECL); 3.37 } 3.38 + if(header!=null) { 3.39 + textBuffer.set(header); 3.40 + textBuffer.write(this); 3.41 + } 3.42 } 3.43 3.44 public void endDocument(boolean fragment) throws IOException, SAXException, XMLStreamException { 3.45 @@ -383,11 +397,23 @@ 3.46 return buf; 3.47 } 3.48 3.49 - private static final byte[] XMLNS_EQUALS = toBytes(" xmlns=\""); 3.50 - private static final byte[] XMLNS_COLON = toBytes(" xmlns:"); 3.51 - private static final byte[] EQUALS = toBytes("=\""); 3.52 - private static final byte[] CLOSE_TAG = toBytes("</"); 3.53 - private static final byte[] EMPTY_TAG = toBytes("/>"); 3.54 + // per instance copy to prevent an attack where malicious OutputStream 3.55 + // rewrites the byte array. 3.56 + private final byte[] XMLNS_EQUALS = _XMLNS_EQUALS.clone(); 3.57 + private final byte[] XMLNS_COLON = _XMLNS_COLON.clone(); 3.58 + private final byte[] EQUALS = _EQUALS.clone(); 3.59 + private final byte[] CLOSE_TAG = _CLOSE_TAG.clone(); 3.60 + private final byte[] EMPTY_TAG = _EMPTY_TAG.clone(); 3.61 + private final byte[] XML_DECL = _XML_DECL.clone(); 3.62 + 3.63 + // masters 3.64 + private static final byte[] _XMLNS_EQUALS = toBytes(" xmlns=\""); 3.65 + private static final byte[] _XMLNS_COLON = toBytes(" xmlns:"); 3.66 + private static final byte[] _EQUALS = toBytes("=\""); 3.67 + private static final byte[] _CLOSE_TAG = toBytes("</"); 3.68 + private static final byte[] _EMPTY_TAG = toBytes("/>"); 3.69 + private static final byte[] _XML_DECL = toBytes("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); 3.70 + 3.71 + // no need to copy 3.72 private static final byte[] EMPTY_BYTE_ARRAY = new byte[0]; 3.73 - private static final byte[] XML_DECL = toBytes("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>"); 3.74 }