< prev index next >

jaxws/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/marshaller/MinimumEscapeHandler.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 46,59 **** // that the escaping occurs rarely. // profiling revealed that this is faster than the naive code. int limit = start+length; for (int i = start; i < limit; i++) { char c = ch[i]; ! if(c == '&' || c == '<' || c == '>' || c == '\r' || (c == '\"' && isAttVal) ) { ! if(i!=start) ! out.write(ch,start,i-start); ! start = i+1; switch (ch[i]) { case '&': out.write("&amp;"); break; case '<': --- 46,59 ---- // that the escaping occurs rarely. // profiling revealed that this is faster than the naive code. int limit = start+length; for (int i = start; i < limit; i++) { char c = ch[i]; ! if (c == '&' || c == '<' || c == '>' || c == '\r' || (c == '\n' && isAttVal) || (c == '\"' && isAttVal)) { ! if (i != start) ! out.write(ch, start, i - start); ! start = i + 1; switch (ch[i]) { case '&': out.write("&amp;"); break; case '<':
*** 63,72 **** --- 63,80 ---- out.write("&gt;"); break; case '\"': out.write("&quot;"); break; + case '\n': + case '\r': + out.write("&#"); + out.write(Integer.toString(c)); + out.write(';'); + break; + default: + throw new IllegalArgumentException("Cannot escape: '" + c + "'"); } } } if( start!=limit )
< prev index next >