From 842623b73f3bc22c3075d09037aacf70d1191dae Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Fri, 1 Apr 2011 16:27:03 +0000 Subject: [PATCH] Tweak 7 bit guessing code git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1087788 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/org/apache/poi/hsmf/MAPIMessage.java | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java index 1b3d493980..4d00e79e41 100644 --- a/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java +++ b/src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java @@ -362,20 +362,18 @@ public class MAPIMessage extends POIDocument { public void guess7BitEncoding() { try { String[] headers = getHeaders(); - if(headers == null || headers.length == 0) { - return; - } - - // Look for a content type with a charset - Pattern p = Pattern.compile("Content-Type:.*?charset=[\"']?(.*?)[\"']?"); - for(String header : headers) { - if(header.startsWith("Content-Type")) { - Matcher m = p.matcher(header); - if(m.matches()) { - // Found it! Tell all the string chunks - String charset = m.group(1); - set7BitEncoding(charset); - return; + if(headers != null && headers.length > 0) { + // Look for a content type with a charset + Pattern p = Pattern.compile("Content-Type:.*?charset=[\"']?(.*?)[\"']?"); + for(String header : headers) { + if(header.startsWith("Content-Type")) { + Matcher m = p.matcher(header); + if(m.matches()) { + // Found it! Tell all the string chunks + String charset = m.group(1); + set7BitEncoding(charset); + return; + } } } } @@ -384,17 +382,18 @@ public class MAPIMessage extends POIDocument { // Nothing suitable in the headers, try HTML try { String html = getHmtlBody(); - - // Look for a content type in the meta headers - Pattern p = Pattern.compile( - " 0) { + // Look for a content type in the meta headers + Pattern p = Pattern.compile( + "