Skip to content

Commit

Permalink
Fix getString in COSString
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximPlusov committed Dec 18, 2024
1 parent 23f2274 commit 209cf26
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/verapdf/cos/COSString.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ public Double getReal() {

@Override
public String getString() {
if (value.length > 2) {
if (value.length >= 2) {
if ((value[0] & 0xFF) == 0xFE && (value[1] & 0xFF) == 0xFF) {
return new String(value, 2, value.length - 2, StandardCharsets.UTF_16BE);
}
if ((value[0] & 0xFF) == 0xFF && (value[1] & 0xFF) == 0xFE) {
LOGGER.log(Level.WARNING, "String object uses encoding UTF16-LE not supported by PDF");
}
}
if (value.length > 3) {
if (value.length >= 3) {
if ((value[0] & 0xFF) == 0xEF && (value[1] & 0xFF) == 0xBB && (value[2] & 0xFF) == 0xBF) {
return new String(value, 3, value.length - 3, StandardCharsets.UTF_8);
}
Expand Down

0 comments on commit 209cf26

Please sign in to comment.