From 8a6a9e1344f5b10ebfa1a189dc3c30d0da2b9d4b Mon Sep 17 00:00:00 2001 From: tballison Date: Fri, 25 May 2018 10:40:47 -0400 Subject: [PATCH] fix logic in iptc parser --- .../org/apache/tika/parser/iptc/IptcAnpaParser.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tika-parsers/src/main/java/org/apache/tika/parser/iptc/IptcAnpaParser.java b/tika-parsers/src/main/java/org/apache/tika/parser/iptc/IptcAnpaParser.java index 3904244837..9a3e4acf06 100644 --- a/tika-parsers/src/main/java/org/apache/tika/parser/iptc/IptcAnpaParser.java +++ b/tika-parsers/src/main/java/org/apache/tika/parser/iptc/IptcAnpaParser.java @@ -463,7 +463,7 @@ private boolean parseBody(byte[] value, HashMap properties) { while ((val_next != LT) && (val_next != CR) && (val_next != LF)) { // less than delimiter (\x3c) and not EOL bdy_heading += (char)(val_next & 0xff); // convert the byte to an unsigned int val_next = (read < value.length) ? value[read++] : 0x00; - if (read > value.length) { break; } // shouldn't ever hit this, but save a NPE + if (read >= value.length) { break; } // shouldn't ever hit this, but save a NPE } if (val_next == LT) { // hit the delimiter, carry on @@ -508,7 +508,7 @@ private boolean parseBody(byte[] value, HashMap properties) { while ((val_next != LT) && (val_next != CT) && (val_next != CR) && (val_next != LF)) { // less than delimiter (\x3c), or carat (\x5e) and not EOL bdy_title += (char)(val_next & 0xff); // convert the byte to an unsigned int val_next = (read < value.length) ? value[read++] : 0x00; - if (read > value.length) { break; } // shouldn't ever hit this, but save a NPE + if (read >= value.length) { break; } // shouldn't ever hit this, but save a NPE } if (val_next == CT) { // start of a new section , when first didn't finish cleanly @@ -575,7 +575,7 @@ private boolean parseBody(byte[] value, HashMap properties) { // less than delimiter (\x3c), maybe also badly formed with just new line tmp_line += (char)(val_next & 0xff); // convert the byte to an unsigned int val_next = (read < value.length) ? value[read++] : 0x00; - if (read > value.length) { break; } // shouldn't ever hit this, but save a NPE + if (read >= value.length) { break; } // shouldn't ever hit this, but save a NPE } if (val_next == CT) { // start of a new section , when first didn't finish cleanly @@ -674,7 +674,7 @@ else if (tmp_line.toLowerCase(Locale.ROOT).startsWith("eds") || longline.equals( // read until the train runs out of tracks bdy_body += (char)(val_next & 0xff); // convert the byte to an unsigned int val_next = (read < value.length) ? value[read++] : 0x00; - if (read > value.length) { break; } // shouldn't ever hit this, but save a NPE + if (read >= value.length) { break; } // shouldn't ever hit this, but save a NPE } } @@ -713,14 +713,14 @@ private boolean parseFooter(byte[] value, HashMap properties) { ftr_source += (char)(val_next & 0xff); // convert the byte to an unsigned int val_next = (read < value.length) ? value[read] : 0x00; // attempt to read until end of stream read++; - if (read > value.length) { break; } // shouldn't ever hit this, but save a NPE + if (read >= value.length) { break; } // shouldn't ever hit this, but save a NPE } while ((val_next != LT) && (val_next != CR) && (val_next != LF) && (val_next != 0)) { // get as much timedate as possible // this is an american format, so arrives as mm-dd-yy HHiizzz ftr_datetime += (char)(val_next & 0xff); // convert the byte to an unsigned int val_next = (read < value.length) ? value[read++] : 0x00; // skip the new lines - if (read > value.length) { break; } // shouldn't ever hit this, but save a NPE + if (read >= value.length) { break; } // shouldn't ever hit this, but save a NPE } if (val_next == LT) { // hit the delimiter, carry on