--- old/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/marshaller/MinimumEscapeHandler.java 2017-05-03 18:05:13.591096075 +0300 +++ new/src/java.xml.bind/share/classes/com/sun/xml/internal/bind/marshaller/MinimumEscapeHandler.java 2017-05-03 18:05:13.491096078 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -48,10 +48,10 @@ 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; + 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("&"); @@ -65,6 +65,14 @@ case '\"': out.write("""); break; + case '\n': + case '\r': + out.write("&#"); + out.write(Integer.toString(c)); + out.write(';'); + break; + default: + throw new IllegalArgumentException("Cannot escape: '" + c + "'"); } } }