You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tika.apache.org by ta...@apache.org on 2022/06/01 15:10:14 UTC
[tika] branch main updated: TIKA-3710 - update mime detection for rfc822, again.
This is an automated email from the ASF dual-hosted git repository.
tallison pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tika.git
The following commit(s) were added to refs/heads/main by this push:
new a52e4d153 TIKA-3710 - update mime detection for rfc822, again.
a52e4d153 is described below
commit a52e4d153e950077f7fdedadcc5d75604fe2563d
Author: tballison <ta...@apache.org>
AuthorDate: Wed Jun 1 11:10:05 2022 -0400
TIKA-3710 - update mime detection for rfc822, again.
---
.../resources/org/apache/tika/mime/tika-mimetypes.xml | 12 ++++--------
.../test/java/org/apache/tika/mime/TestMimeTypes.java | 5 +++++
.../test-documents/testBrokenHTMLContainingRFC822.html | 17 +++++++++++++++++
3 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
index db7359608..2329c0a3b 100644
--- a/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
+++ b/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
@@ -6737,6 +6737,10 @@
<root-XML localName="SCRIPT"/>
<root-XML localName="frameset"/>
<root-XML localName="FRAMESET"/>
+ <magic priority="60">
+ <match value="(?i)<(html|head|body|title|div)[ >]" type="regex" offset="0"/>
+ <match value="(?i)<h[123][ >]" type="regex" offset="0"/>
+ </magic>
<!-- The magic priority needs to be lower than that of -->
<!-- files which contain HTML within them, eg mime emails -->
<magic priority="40">
@@ -6749,14 +6753,6 @@
<match value="<TITLE" type="string" offset="0:64"/>
<match value="<title" type="string" offset="0:64"/>
<match value="<HTML" type="string" offset="0:64"/>
- <match value="<BODY" type="string" offset="0"/>
- <match value="<body" type="string" offset="0"/>
- <match value="<DIV" type="string" offset="0"/>
- <match value="<div" type="string" offset="0"/>
- <match value="<TITLE" type="string" offset="0"/>
- <match value="<title" type="string" offset="0"/>
- <match value="<h1" type="string" offset="0"/>
- <match value="<H1" type="string" offset="0"/>
<match value="<html" type="string" offset="0:128"/>
</magic>
<magic priority="20">
diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/TestMimeTypes.java b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/TestMimeTypes.java
index a7aaada50..a90d27272 100644
--- a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/TestMimeTypes.java
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/java/org/apache/tika/mime/TestMimeTypes.java
@@ -1279,6 +1279,11 @@ public class TestMimeTypes {
assertTypeByData("application/vnd.java.hprof.text", "testJavaHprofText");
}
+ @Test
+ public void testHTMLSnippetWithRFC822() throws Exception {
+ assertTypeByData("text/html", "testBrokenHTMLContainingRFC822.html");
+ }
+
private void assertText(byte[] prefix) throws IOException {
assertMagic("text/plain", prefix);
}
diff --git a/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/resources/test-documents/testBrokenHTMLContainingRFC822.html b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/resources/test-documents/testBrokenHTMLContainingRFC822.html
new file mode 100644
index 000000000..8b7b2cecb
--- /dev/null
+++ b/tika-parsers/tika-parsers-standard/tika-parsers-standard-package/src/test/resources/test-documents/testBrokenHTMLContainingRFC822.html
@@ -0,0 +1,17 @@
+<h1>A heading</h1>
+<hr>
+Some text<br>
+<div dir="ltr">Yes</div>
+<div class="gmail_extra"><br>
+<div class="gmail_quote">
+<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Some stuff<br>
+<br>
+-----Original Message-----<br>
+From: someone@somewhere.com
+Sent: Thursday, September 6, 2018 1:07 PM<br>
+Subject: An exciting subject<br>
+<br>
+A whole bunch of text.
+</blockquote>
+</div>
+</div>