Tweak 7 bit guessing code
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1087788 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9f40e3df71
commit
aad03b8cd3
@ -362,10 +362,7 @@ public class MAPIMessage extends POIDocument {
|
|||||||
public void guess7BitEncoding() {
|
public void guess7BitEncoding() {
|
||||||
try {
|
try {
|
||||||
String[] headers = getHeaders();
|
String[] headers = getHeaders();
|
||||||
if(headers == null || headers.length == 0) {
|
if(headers != null && headers.length > 0) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Look for a content type with a charset
|
// Look for a content type with a charset
|
||||||
Pattern p = Pattern.compile("Content-Type:.*?charset=[\"']?(.*?)[\"']?");
|
Pattern p = Pattern.compile("Content-Type:.*?charset=[\"']?(.*?)[\"']?");
|
||||||
for(String header : headers) {
|
for(String header : headers) {
|
||||||
@ -379,12 +376,13 @@ public class MAPIMessage extends POIDocument {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch(ChunkNotFoundException e) {}
|
} catch(ChunkNotFoundException e) {}
|
||||||
|
|
||||||
// Nothing suitable in the headers, try HTML
|
// Nothing suitable in the headers, try HTML
|
||||||
try {
|
try {
|
||||||
String html = getHmtlBody();
|
String html = getHmtlBody();
|
||||||
|
if(html != null && html.length() > 0) {
|
||||||
// Look for a content type in the meta headers
|
// Look for a content type in the meta headers
|
||||||
Pattern p = Pattern.compile(
|
Pattern p = Pattern.compile(
|
||||||
"<META\\s+HTTP-EQUIV=\"Content-Type\"\\s+CONTENT=\"text/html;\\s+charset=(.*?)\""
|
"<META\\s+HTTP-EQUIV=\"Content-Type\"\\s+CONTENT=\"text/html;\\s+charset=(.*?)\""
|
||||||
@ -396,6 +394,7 @@ public class MAPIMessage extends POIDocument {
|
|||||||
set7BitEncoding(charset);
|
set7BitEncoding(charset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch(ChunkNotFoundException e) {}
|
} catch(ChunkNotFoundException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user