Index: tika-parsers/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java
===================================================================
--- tika-parsers/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java	(revision 1213232)
+++ tika-parsers/src/test/java/org/apache/tika/detect/TestContainerAwareDetector.java	(working copy)
@@ -70,6 +70,7 @@
         assertTypeByData("testPUBLISHER.pub", "application/x-mspublisher");
         assertTypeByData("testWORKS.wps", "application/vnd.ms-works");
         assertTypeByData("testWORKS2000.wps", "application/vnd.ms-works");
+        assertTypeByData("testWORKSSpreadsheet7.0.xlr", "application/vnd.ms-works");
         assertTypeByData("testPROJECT2003.mpp", "application/vnd.ms-project");
         assertTypeByData("testPROJECT2007.mpp", "application/vnd.ms-project");
 
Index: tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java
===================================================================
--- tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java	(revision 1213232)
+++ tika-parsers/src/test/java/org/apache/tika/mime/TestMimeTypes.java	(working copy)
@@ -1,5 +1,5 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
+* Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
  * this work for additional information regarding copyright ownership.
  * The ASF licenses this file to You under the Apache License, Version 2.0
@@ -128,7 +128,7 @@
     public void testOLE2Detection() throws Exception {
         // These have the properties block near the start, so our mime
         //  magic will spot them
-        assertTypeByData("application/vnd.ms-excel", "testEXCEL.xls");
+        assertTypeByData("application/x-tika-msoffice", "testEXCEL.xls");
         
         // This one quite legitimately doesn't have its properties block
         //  as one of the first couple of entries
@@ -136,6 +136,7 @@
         assertTypeByData("application/x-tika-msoffice", "testWORD.doc");
         assertTypeByData("application/x-tika-msoffice", "testPPT.ppt");
         
+        assertTypeByData("application/x-tika-msoffice", "testWORKSSpreadsheet7.0.xlr");
         
         // By name + data:
         
@@ -146,6 +147,8 @@
         //  ones to their actual type
         assertTypeByNameAndData("application/vnd.ms-powerpoint", "testPPT.ppt");
         assertTypeByNameAndData("application/msword", "testWORD.doc");
+        
+        assertTypeByNameAndData("application/vnd.ms-works", "testWORKSSpreadsheet7.0.xlr");
     }
     
     /**
Index: tika-parsers/src/main/java/org/apache/tika/parser/microsoft/POIFSContainerDetector.java
===================================================================
--- tika-parsers/src/main/java/org/apache/tika/parser/microsoft/POIFSContainerDetector.java	(revision 1213232)
+++ tika-parsers/src/main/java/org/apache/tika/parser/microsoft/POIFSContainerDetector.java	(working copy)
@@ -133,7 +133,9 @@
      */
     protected static MediaType detect(Set<String> names) {
         if (names != null) {
-            if (names.contains("Workbook")) {
+            if (names.contains("WksSSWorkBook")) {
+                return WPS; // a Works 7.0 spreadsheet file
+            } if (names.contains("Workbook")) {
                 return XLS;
             } else if (names.contains("EncryptedPackage") && 
                     names.contains("EncryptionInfo") &&
Index: tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java
===================================================================
--- tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java	(revision 1213232)
+++ tika-core/src/test/java/org/apache/tika/mime/MimeDetectionTest.java	(working copy)
@@ -174,13 +174,35 @@
 
     /**
      * Tests that when we repeatedly test the detection of a document
-     *  that can be detected with Mime Magic, that we consistently
-     *  detect it correctly. See TIKA-391 for more details.
+     * that can be detected with Mime Magic, that we consistently
+     * detect it correctly. See TIKA-391 for more details.
+     *  
+     * In TIKA-806 I removed the patterns, which allowed the test.xls
+     * file to be detected based on the magic only. Since then, the
+     * expected media type for this file is application/x-tika-msoffice
+     * when detected without the RESOURCE_NAME hint, and the normal
+     * Excel media type when detected with the hint. 
      */
     public void testMimeMagicStability() throws IOException {
+        
        for(int i=0; i<100; i++) {
-          testFile("application/vnd.ms-excel", "test.xls");
+           InputStream in = getClass().getResourceAsStream("test.xls");
+           assertNotNull("Test stream: [test.xls] is null!", in);
+           if (!in.markSupported()) {
+               in = new java.io.BufferedInputStream(in);
+           }
+           try {
+               Metadata metadata = new Metadata();
+               String mime = this.mimeTypes.detect(in, metadata).toString();
+               assertEquals("test.xls is not properly detected: detected.", "application/x-tika-msoffice", mime);
+
+               //Add resource name and test again
+               metadata.set(Metadata.RESOURCE_NAME_KEY, "test.xls");
+               mime = this.mimeTypes.detect(in, metadata).toString();
+               assertEquals("test.xls is not properly detected after adding resource name.", "application/vnd.ms-excel", mime);
+           } finally {
+               in.close();
+           }   
        }
     }
-
 }
Index: tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
===================================================================
--- tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml	(revision 1213232)
+++ tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml	(working copy)
@@ -264,9 +264,6 @@
       <match value="\354\245\301" type="string" offset="512"/>
       <match value="\320\317\021\340\241\261\032\341" type="string" offset="0"/>
       <match value="\224\246\056" type="string" offset="0"/>
-      <match value="0xd0cf11e0a1b11ae1" type="string" offset="0:8">
-         <match value="W\x00o\x00r\x00d\x00D\x00o\x00c\x00u\x00m\x00e\x00n\x00t" type="string" offset="1152:4096" />
-      </match>
     </magic>
     <glob pattern="*.doc"/>
     <glob pattern="*.dot"/>
@@ -1213,9 +1210,6 @@
       <match value="Biff5" type="string" offset="2114"/>
       <match value="Biff5" type="string" offset="2121"/>
       <match value="\x09\x04\x06\x00\x00\x00\x10\x00" type="string" offset="0"/>
-      <match value="0xd0cf11e0a1b11ae1" type="string" offset="0:8">
-         <match value="W\x00o\x00r\x00k\x00b\x00o\x00o\x00k" type="string" offset="1152:4096" />
-      </match>
     </magic>
     <glob pattern="*.xls"/>
     <glob pattern="*.xlm"/>
@@ -1283,11 +1277,6 @@
     <!-- Use org.apache.tika.detect.ContainerAwareDetector for more reliable detection of OLE2 documents -->
     <alias type="application/mspowerpoint"/>
     <_comment>Microsoft Powerpoint Presentation</_comment>
-    <magic priority="50">
-      <match value="0xd0cf11e0a1b11ae1" type="string" offset="0:8">
-         <match value="P\x00o\x00w\x00e\x00r\x00P\x00o\x00i\x00n\x00t\x00 D\x00o\x00c\x00u\x00m\x00e\x00n\x00t" type="string" offset="1152:4096" />
-      </match>
-    </magic>
     <glob pattern="*.ppt"/>
     <glob pattern="*.ppz"/>
     <glob pattern="*.pps"/>
@@ -1359,6 +1348,7 @@
     <glob pattern="*.wks"/>
     <glob pattern="*.wcm"/>
     <glob pattern="*.wdb"/>
+    <glob pattern="*.xlr"/>
     <sub-class-of type="application/x-tika-msoffice"/>
   </mime-type>
 
