mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 22:34:27 +02:00
8200530: '\r' is not supported as "newline" in java.util.jar.Manifest
Reviewed-by: jlaskey
This commit is contained in:
parent
8b4b130011
commit
fcfd1c85dd
3 changed files with 134 additions and 4 deletions
|
@ -377,7 +377,8 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
int len;
|
||||
while ((len = is.readLine(lbuf)) != -1) {
|
||||
boolean lineContinued = false;
|
||||
if (lbuf[--len] != '\n') {
|
||||
byte c = lbuf[--len];
|
||||
if (c != '\n' && c != '\r') {
|
||||
throw new IOException("line too long");
|
||||
}
|
||||
if (len > 0 && lbuf[len-1] == '\r') {
|
||||
|
|
|
@ -205,7 +205,8 @@ public class Manifest implements Cloneable {
|
|||
byte[] lastline = null;
|
||||
|
||||
while ((len = fis.readLine(lbuf)) != -1) {
|
||||
if (lbuf[--len] != '\n') {
|
||||
byte c = lbuf[--len];
|
||||
if (c != '\n' && c != '\r') {
|
||||
throw new IOException("manifest line too long");
|
||||
}
|
||||
if (len > 0 && lbuf[len-1] == '\r') {
|
||||
|
@ -381,13 +382,18 @@ public class Manifest implements Cloneable {
|
|||
}
|
||||
int tpos = pos;
|
||||
int maxpos = tpos + n;
|
||||
while (tpos < maxpos && tbuf[tpos++] != '\n') ;
|
||||
byte c = 0;
|
||||
// jar.spec.newline: CRLF | LF | CR (not followed by LF)
|
||||
while (tpos < maxpos && (c = tbuf[tpos++]) != '\n' && c != '\r');
|
||||
if (c == '\r' && tpos < maxpos && tbuf[tpos] == '\n') {
|
||||
tpos++;
|
||||
}
|
||||
n = tpos - pos;
|
||||
System.arraycopy(tbuf, pos, b, off, n);
|
||||
off += n;
|
||||
total += n;
|
||||
pos = tpos;
|
||||
if (tbuf[tpos-1] == '\n') {
|
||||
if (c == '\n' || c == '\r') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue