Author: nick
Date: Mon Dec 13 02:41:59 2010
New Revision: 1045006

URL: http://svn.apache.org/viewvc?rev=1045006&view=rev
Log:
Apply patch from TIKA-570 from Benson Margulies - stricter BMP detection and 
unit test

Added:
    tika/trunk/tika-parsers/src/test/resources/test-documents/testBMPfp.txt
Modified:
    
tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
    
tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java

Modified: 
tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
URL: 
http://svn.apache.org/viewvc/tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml?rev=1045006&r1=1045005&r2=1045006&view=diff
==============================================================================
--- 
tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml 
(original)
+++ 
tika/trunk/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml 
Mon Dec 13 02:41:59 2010
@@ -3125,7 +3125,17 @@
     <acronym>BMP</acronym>
     <_comment>Windows bitmap</_comment>
     <magic priority="50">
-      <match value="BM" type="string" offset="0" />
+      <match value="BM" type="string" offset="0">
+        <match value="0x0100" type="string" offset="26">
+         <match value="0x0000" type="string" offset="28"/>
+         <match value="0x0100" type="string" offset="28"/>
+         <match value="0x0400" type="string" offset="28"/>
+         <match value="0x0800" type="string" offset="28"/>
+         <match value="0x1000" type="string" offset="28"/>
+         <match value="0x1800" type="string" offset="28"/>
+         <match value="0x2000" type="string" offset="28"/>
+        </match>
+      </match>
     </magic>
     <glob pattern="*.bmp"/>
     <glob pattern="*.dib"/>

Modified: 
tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
URL: 
http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java?rev=1045006&r1=1045005&r2=1045006&view=diff
==============================================================================
--- 
tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java 
(original)
+++ 
tika/trunk/tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java 
Mon Dec 13 02:41:59 2010
@@ -191,6 +191,8 @@ public class TestMimeTypes extends TestC
         assertTypeByName("image/x-ms-bmp", "x.BMP");
         assertTypeByName("image/x-ms-bmp", "x.dib");
         assertTypeByName("image/x-ms-bmp", "x.DIB");
+        //false positive check -- contains part of BMP signature
+        assertType("text/plain", "testBMPfp.txt");
     }
 
     public void testPnmDetection() throws Exception {

Added: tika/trunk/tika-parsers/src/test/resources/test-documents/testBMPfp.txt
URL: 
http://svn.apache.org/viewvc/tika/trunk/tika-parsers/src/test/resources/test-documents/testBMPfp.txt?rev=1045006&view=auto
==============================================================================
--- tika/trunk/tika-parsers/src/test/resources/test-documents/testBMPfp.txt 
(added)
+++ tika/trunk/tika-parsers/src/test/resources/test-documents/testBMPfp.txt Mon 
Dec 13 02:41:59 2010
@@ -0,0 +1,3 @@
+BMW to Make Hybrid Sports Car

+ By CHRISTOPH RAUWALD . 
+LEIPZIG, Germany—German car maker BMW AG said Friday it will start series 
production of a new plug-in hybrid sports car in 2013, to be based on the 
Vision EfficientDynamics Concept car shown at the Frankfurt auto show in 
September last year. Chief Executive Norbert Reithofer said the car will be 
produced in Germany but didn't provide details on the price. The BMW Vision 
EfficientDynamics Concept car is a sporty plug-in, full hybrid with a 
turbo-diesel engine, four seats and upward-pivoting doors. BMW executive board 
member Klaus Draeger told reporters he expects to achieve "a significant sales 
volume" with the new high-performance sports car. Asked whether annual sales 
could exceed 1,000 vehicles, Mr. Draeger said, "You said this and I'm not 
saying this is wrong." In March, Mr. Reithofer indicated that the concept car 
was set to make it into series production. "I like the car. And you know what 
it means when I say I like the car—it means I will drive it. It's not j
 ust a concept car," he told analysts during a presentation in Munich. The car 
will be designed for sale in all major global markets, which according to Mr. 
Draeger might require offering a gasoline engine instead of the prototype's 
three-cylinder diesel engine. Diesel cars account for roughly half of the 
European market, but are significantly less popular in the U.S. and hardly 
present at all in China. Mr. Draeger declined to comment on the vehicle's price 
tag, but noted that in order to achieve substantial sales volumes the price 
mustn't be too high. He said the same goes for BMW's planned Megacity Vehicle. 
A price tag of €60,000 ($85,242) or more would certainly limit potential 
sales volumes, he said. 


Reply via email to