Skip to content

Commit cc574e1

Browse files
committed
Fix getString in COSString
1 parent 29e0a76 commit cc574e1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/verapdf/cos/COSString.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,15 @@ public Double getReal() {
106106

107107
@Override
108108
public String getString() {
109-
if (value.length > 2) {
109+
if (value.length >= 2) {
110110
if ((value[0] & 0xFF) == 0xFE && (value[1] & 0xFF) == 0xFF) {
111111
return new String(value, 2, value.length - 2, StandardCharsets.UTF_16BE);
112112
}
113113
if ((value[0] & 0xFF) == 0xFF && (value[1] & 0xFF) == 0xFE) {
114114
LOGGER.log(Level.WARNING, "String object uses encoding UTF16-LE not supported by PDF");
115115
}
116116
}
117-
if (value.length > 3) {
117+
if (value.length >= 3) {
118118
if ((value[0] & 0xFF) == 0xEF && (value[1] & 0xFF) == 0xBB && (value[2] & 0xFF) == 0xBF) {
119119
return new String(value, 3, value.length - 3, StandardCharsets.UTF_8);
120120
}

0 commit comments

Comments
 (0)