[QuickLook] Use case-insensitive comparison of preview MIME types
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Aug 2017 15:52:19 +0000 (15:52 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Aug 2017 15:52:19 +0000 (15:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175350
<rdar://problem/33761159>

Reviewed by Brady Eidson.

Source/WebCore:

MIME types are case-insensitive, but PreviewLoader was using a case-sensitive comparison to
determine if a MIME type was supported by QLPreviewConverter. As a result we would fail to
preview Excel macro-enabled workbooks, since CFNetwork would sniff a MIME type of
"application/vnd.ms-excel.sheet.macroEnabled.12" but QuickLook contained
"application/vnd.ms-excel.sheet.macroenabled.12" in its set of supported MIME type strings.

Fix this by copying the QuickLook supported MIME type set into a HashSet using
ASCIICaseInsensitiveHash and using that HashSet for MIME type checks.

Test: quicklook/excel-macro-enabled.html

* loader/ios/PreviewLoader.mm:
(WebCore::PreviewLoader::shouldCreateForMIMEType):

LayoutTests:

* platform/ios-11/quicklook/excel-macro-enabled-expected.txt: Added.
* quicklook/excel-macro-enabled-expected.txt: Added.
* quicklook/excel-macro-enabled.html: Added.
* quicklook/resources/excel-macro-enabled.xlsm: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@220456 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/platform/ios-11/quicklook/excel-macro-enabled-expected.txt [new file with mode: 0644]
LayoutTests/quicklook/excel-macro-enabled-expected.txt [new file with mode: 0644]
LayoutTests/quicklook/excel-macro-enabled.html [new file with mode: 0644]
LayoutTests/quicklook/resources/excel-macro-enabled.xlsm [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/loader/ios/PreviewLoader.mm

index 06b2b2b..0c78b73 100644 (file)
@@ -1,3 +1,16 @@
+2017-08-09  Andy Estes  <aestes@apple.com>
+
+        [QuickLook] Use case-insensitive comparison of preview MIME types
+        https://bugs.webkit.org/show_bug.cgi?id=175350
+        <rdar://problem/33761159>
+
+        Reviewed by Brady Eidson.
+
+        * platform/ios-11/quicklook/excel-macro-enabled-expected.txt: Added.
+        * quicklook/excel-macro-enabled-expected.txt: Added.
+        * quicklook/excel-macro-enabled.html: Added.
+        * quicklook/resources/excel-macro-enabled.xlsm: Added.
+
 2017-08-09  Zan Dobersek  <zdobersek@igalia.com>
 
         Unreviewed WPE gardening.
diff --git a/LayoutTests/platform/ios-11/quicklook/excel-macro-enabled-expected.txt b/LayoutTests/platform/ios-11/quicklook/excel-macro-enabled-expected.txt
new file mode 100644 (file)
index 0000000..5216461
--- /dev/null
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>WebMainResource</key>
+       <dict>
+               <key>WebResourceData</key>
+               <string>&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;script&gt;
+    if (window.testRunner)
+        testRunner.dumpDOMAsWebArchive();
+&lt;/script&gt;
+&lt;style&gt;
+iframe {
+    width: 100vw;
+    height: 100vh;
+}
+&lt;/style&gt;
+&lt;/head&gt;&lt;body&gt;&lt;iframe src="resources/excel-macro-enabled.xlsm"&gt;&lt;/iframe&gt;
+&lt;/body&gt;&lt;/html&gt;</string>
+               <key>WebResourceFrameName</key>
+               <string></string>
+               <key>WebResourceMIMEType</key>
+               <string>text/html</string>
+               <key>WebResourceTextEncodingName</key>
+               <string>UTF-8</string>
+               <key>WebResourceURL</key>
+               <string>file:///LayoutTests/quicklook/excel-macro-enabled.html</string>
+       </dict>
+       <key>WebSubframeArchives</key>
+       <array>
+               <dict>
+                       <key>WebMainResource</key>
+                       <dict>
+                               <key>WebResourceData</key>
+                               <string>&lt;html&gt;&lt;head&gt;&lt;meta charset="utf-8"&gt;&lt;meta name="viewport"&gt;&lt;link href="x-apple-ql-id://resource.css" rel="stylesheet" type="text/css" charset="utf-8"&gt;&lt;link href="x-apple-ql-id://resource.css" rel="stylesheet" type="text/css" charset="utf-8"&gt;&lt;style type="text/css"&gt;.s0.s0.s0 {font-family:Helvetica;font-size:12px; padding-bottom:0; padding-right:2; padding-left:2; text-align:center; padding-top:0;}
+.s1.s1.s1 {font-family:Helvetica; font-weight:bold; background-color:#bdc0bf; white-space:normal; padding-top:0; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s2.s2.s2 {font-family:Helvetica; font-weight:bold; background-color:#dbdbdb; white-space:normal; padding-top:0; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s3.s3.s3 {font-family:Helvetica; white-space:normal; padding-top:0; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s4.s4.s4 {font-family:Lucida Grande; font-weight:bold;color:#003300;font-size:16px; white-space:normal; vertical-align:top; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; padding-top:0;}
+&lt;/style&gt;&lt;/head&gt;&lt;body&gt;&lt;div&gt;&lt;table class="worksheet"&gt;&lt;colgroup&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;/colgroup&gt;&lt;tbody&gt;&lt;tr height="16;"&gt;&lt;td colspan="9" class="s0"&gt;Table 1&lt;/td&gt;&lt;/tr&gt;&lt;tr height="20;"&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="20;"&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="170;"&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s4"&gt;&lt;div style="width:72; overflow:hidden;"&gt;Welcome to the website for the WebKit Open Source Project!&lt;/div&gt;&lt;/td&gt;&lt;td class="s4"&gt;&lt;div style="width:72; overflow:hidden;"&gt;Welcome to the website for the WebKit Open Source Project!&lt;/div&gt;&lt;/td&gt;&lt;td class="s4"&gt;&lt;div style="width:72; overflow:hidden;"&gt;Welcome to the website for the WebKit Open Source Project!&lt;/div&gt;&lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="338;"&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s3"&gt;&lt;a href="http://www.apple.com/safari/"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit is an open source web browser engine. WebKit is also the name of the OS X system framework version of the engine that's used by &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;Safari&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;, Dashboard, Mail, and many other OS X applications.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s3"&gt;&lt;a href="http://www.apple.com/safari/"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit is an open source web browser engine. WebKit is also the name of the OS X system framework version of the engine that's used by &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;Safari&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;, Dashboard, Mail, and many other OS X applications.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s3"&gt;&lt;a href="http://www.apple.com/safari/"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit is an open source web browser engine. WebKit is also the name of the OS X system framework version of the engine that's used by &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;Safari&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;, Dashboard, Mail, and many other OS X applications.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="158;"&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s3"&gt;&lt;a href="http://konqueror.kde.org/features/browser.php"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit's HTML and JavaScript code began as a branch of the &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KHTML&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt; and KJS libraries from &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KDE&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s3"&gt;&lt;a href="http://konqueror.kde.org/features/browser.php"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit's HTML and JavaScript code began as a branch of the &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KHTML&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt; and KJS libraries from &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KDE&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s3"&gt;&lt;a href="http://konqueror.kde.org/features/browser.php"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit's HTML and JavaScript code began as a branch of the &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KHTML&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt; and KJS libraries from &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KDE&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</string>
+                               <key>WebResourceFrameName</key>
+                               <string>&lt;!--framePath //&lt;!--frame0--&gt;--&gt;</string>
+                               <key>WebResourceMIMEType</key>
+                               <string>text/html</string>
+                               <key>WebResourceTextEncodingName</key>
+                               <string>UTF-8</string>
+                               <key>WebResourceURL</key>
+                               <string>x-apple-ql-id://resource.xlsm</string>
+                       </dict>
+                       <key>WebSubresources</key>
+                       <array>
+                               <dict>
+                                       <key>WebResourceData</key>
+                                       <string>body {
+    font-family: Arial;
+    font-size: 10;
+}
+
+td {
+    white-space: pre;
+    font-family: Arial;
+    font-size: 10;
+}
+
+p {
+    margin:0;
+}
+
+table.worksheet {
+    border-collapse:collapse;
+    table-layout: fixed;
+}
+
+@media screen {
+    .showGridlines, .showGridlines td, .showGridlines th {
+        border: thin solid #d2d2df;
+    }
+}
+</string>
+                                       <key>WebResourceMIMEType</key>
+                                       <string>text/css</string>
+                                       <key>WebResourceResponse</key>
+                                       <dict>
+                                               <key>MIMEType</key>
+                                               <string>text/css</string>
+                                               <key>URL</key>
+                                               <string>x-apple-ql-id://resource.css</string>
+                                               <key>expectedContentLength</key>
+                                               <integer>-1</integer>
+                                               <key>textEncodingName</key>
+                                               <string>UTF-8</string>
+                                       </dict>
+                                       <key>WebResourceTextEncodingName</key>
+                                       <string>UTF-8</string>
+                                       <key>WebResourceURL</key>
+                                       <string>x-apple-ql-id://resource.css</string>
+                               </dict>
+                               <dict>
+                                       <key>WebResourceData</key>
+                                       <string>body {
+    -webkit-text-size-adjust: none;
+}
+</string>
+                                       <key>WebResourceMIMEType</key>
+                                       <string>text/css</string>
+                                       <key>WebResourceResponse</key>
+                                       <dict>
+                                               <key>MIMEType</key>
+                                               <string>text/css</string>
+                                               <key>URL</key>
+                                               <string>x-apple-ql-id://resource.css</string>
+                                               <key>expectedContentLength</key>
+                                               <integer>-1</integer>
+                                               <key>textEncodingName</key>
+                                               <string>UTF-8</string>
+                                       </dict>
+                                       <key>WebResourceTextEncodingName</key>
+                                       <string>UTF-8</string>
+                                       <key>WebResourceURL</key>
+                                       <string>x-apple-ql-id://resource.css</string>
+                               </dict>
+                       </array>
+               </dict>
+       </array>
+</dict>
+</plist>
diff --git a/LayoutTests/quicklook/excel-macro-enabled-expected.txt b/LayoutTests/quicklook/excel-macro-enabled-expected.txt
new file mode 100644 (file)
index 0000000..f4fd77c
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+       <key>WebMainResource</key>
+       <dict>
+               <key>WebResourceData</key>
+               <string>&lt;!DOCTYPE html&gt;&lt;html&gt;&lt;head&gt;&lt;script&gt;
+    if (window.testRunner)
+        testRunner.dumpDOMAsWebArchive();
+&lt;/script&gt;
+&lt;style&gt;
+iframe {
+    width: 100vw;
+    height: 100vh;
+}
+&lt;/style&gt;
+&lt;/head&gt;&lt;body&gt;&lt;iframe src="resources/excel-macro-enabled.xlsm"&gt;&lt;/iframe&gt;
+&lt;/body&gt;&lt;/html&gt;</string>
+               <key>WebResourceFrameName</key>
+               <string></string>
+               <key>WebResourceMIMEType</key>
+               <string>text/html</string>
+               <key>WebResourceTextEncodingName</key>
+               <string>UTF-8</string>
+               <key>WebResourceURL</key>
+               <string>file:///LayoutTests/quicklook/excel-macro-enabled.html</string>
+       </dict>
+       <key>WebSubframeArchives</key>
+       <array>
+               <dict>
+                       <key>WebMainResource</key>
+                       <dict>
+                               <key>WebResourceData</key>
+                               <string>&lt;html&gt;&lt;head&gt;&lt;style type="text/css"&gt;.s0 {font-family:Helvetica;font-size:12px; padding-bottom:0; padding-right:2; padding-left:2; border-style:none; text-align:center; padding-top:0;}
+.s1 {font-family:Helvetica; font-weight:bold; background-color:#bdc0bf; white-space:normal; padding-top:0; padding-bottom:0; border-top-style:solid;border-left-style:none;border-bottom-style:solid;border-right-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s2 {font-family:Helvetica; font-weight:bold; background-color:#bdc0bf; white-space:normal; padding-top:0; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s3 {font-family:Helvetica; font-weight:bold; background-color:#dbdbdb; white-space:normal; padding-top:0; padding-bottom:0; border-top-style:solid;border-left-style:none;border-bottom-style:solid;border-right-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s4 {font-family:Helvetica; white-space:normal; padding-top:0; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; vertical-align:top;}
+.s5 {font-family:Lucida Grande; font-weight:bold;color:#003300;font-size:16px; white-space:normal; vertical-align:top; padding-bottom:0; border-style:solid;border-width:thin;border-color:black; padding-right:2; padding-left:2; padding-top:0;}
+&lt;/style&gt;&lt;style type="text/css"&gt;
+body
+{
+-webkit-text-size-adjust: none;
+}
+td
+{
+white-space: pre;
+font-family: Arial;
+font-size: 10;
+}
+p
+{
+margin:0;
+}
+&lt;/style&gt;&lt;meta charset="utf-8"&gt;&lt;meta name="viewport"&gt;&lt;/head&gt;&lt;body style="font-family:Arial; font-size:10;"&gt;&lt;div&gt;&lt;table style="border-collapse:collapse; table-layout:fixed; width:648; border-style:none; border-color:#d2d2df;"&gt;&lt;colgroup&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;col style="width:73;"&gt;&lt;/colgroup&gt;&lt;tbody&gt;&lt;tr height="16;"&gt;&lt;td colspan="9" class="s0"&gt;Table 1&lt;/td&gt;&lt;/tr&gt;&lt;tr height="20;"&gt;&lt;td class="s1"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;td class="s2"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="20;"&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="170;"&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s5"&gt;&lt;div style="width:72; overflow:hidden;"&gt;Welcome to the website for the WebKit Open Source Project!&lt;/div&gt;&lt;/td&gt;&lt;td class="s5"&gt;&lt;div style="width:72; overflow:hidden;"&gt;Welcome to the website for the WebKit Open Source Project!&lt;/div&gt;&lt;/td&gt;&lt;td class="s5"&gt;&lt;div style="width:72; overflow:hidden;"&gt;Welcome to the website for the WebKit Open Source Project!&lt;/div&gt;&lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="338;"&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s4"&gt;&lt;a href="http://www.apple.com/safari/"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit is an open source web browser engine. WebKit is also the name of the OS X system framework version of the engine that's used by &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;Safari&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;, Dashboard, Mail, and many other OS X applications.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s4"&gt;&lt;a href="http://www.apple.com/safari/"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit is an open source web browser engine. WebKit is also the name of the OS X system framework version of the engine that's used by &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;Safari&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;, Dashboard, Mail, and many other OS X applications.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s4"&gt;&lt;a href="http://www.apple.com/safari/"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit is an open source web browser engine. WebKit is also the name of the OS X system framework version of the engine that's used by &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;Safari&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;, Dashboard, Mail, and many other OS X applications.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;tr height="158;"&gt;&lt;td class="s3"&gt; &lt;/td&gt;&lt;td class="s4"&gt;&lt;a href="http://konqueror.kde.org/features/browser.php"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit's HTML and JavaScript code began as a branch of the &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KHTML&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt; and KJS libraries from &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KDE&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s4"&gt;&lt;a href="http://konqueror.kde.org/features/browser.php"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit's HTML and JavaScript code began as a branch of the &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KHTML&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt; and KJS libraries from &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KDE&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s4"&gt;&lt;a href="http://konqueror.kde.org/features/browser.php"&gt;&lt;div style="width:72; overflow:hidden;"&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;WebKit's HTML and JavaScript code began as a branch of the &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KHTML&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt; and KJS libraries from &lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#228711;font-size:12px;"&gt;KDE&lt;/span&gt;&lt;span style="font-family:Lucida Grande;color:#323232;font-size:12px;"&gt;.&lt;/span&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;td class="s4"&gt; &lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;</string>
+                               <key>WebResourceFrameName</key>
+                               <string>&lt;!--framePath //&lt;!--frame0--&gt;--&gt;</string>
+                               <key>WebResourceMIMEType</key>
+                               <string>text/html</string>
+                               <key>WebResourceTextEncodingName</key>
+                               <string>UTF-8</string>
+                               <key>WebResourceURL</key>
+                               <string>x-apple-ql-id://resource.xlsm</string>
+                       </dict>
+               </dict>
+       </array>
+</dict>
+</plist>
diff --git a/LayoutTests/quicklook/excel-macro-enabled.html b/LayoutTests/quicklook/excel-macro-enabled.html
new file mode 100644 (file)
index 0000000..795e173
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<script>
+    if (window.testRunner)
+        testRunner.dumpDOMAsWebArchive();
+</script>
+<style>
+iframe {
+    width: 100vw;
+    height: 100vh;
+}
+</style>
+<iframe src="resources/excel-macro-enabled.xlsm"></iframe>
diff --git a/LayoutTests/quicklook/resources/excel-macro-enabled.xlsm b/LayoutTests/quicklook/resources/excel-macro-enabled.xlsm
new file mode 100644 (file)
index 0000000..e41aca9
Binary files /dev/null and b/LayoutTests/quicklook/resources/excel-macro-enabled.xlsm differ
index 9b54ce1..88fa46e 100644 (file)
@@ -1,3 +1,25 @@
+2017-08-09  Andy Estes  <aestes@apple.com>
+
+        [QuickLook] Use case-insensitive comparison of preview MIME types
+        https://bugs.webkit.org/show_bug.cgi?id=175350
+        <rdar://problem/33761159>
+
+        Reviewed by Brady Eidson.
+
+        MIME types are case-insensitive, but PreviewLoader was using a case-sensitive comparison to
+        determine if a MIME type was supported by QLPreviewConverter. As a result we would fail to
+        preview Excel macro-enabled workbooks, since CFNetwork would sniff a MIME type of
+        "application/vnd.ms-excel.sheet.macroEnabled.12" but QuickLook contained
+        "application/vnd.ms-excel.sheet.macroenabled.12" in its set of supported MIME type strings.
+
+        Fix this by copying the QuickLook supported MIME type set into a HashSet using
+        ASCIICaseInsensitiveHash and using that HashSet for MIME type checks.
+
+        Test: quicklook/excel-macro-enabled.html
+
+        * loader/ios/PreviewLoader.mm:
+        (WebCore::PreviewLoader::shouldCreateForMIMEType):
+
 2017-08-09  Ms2ger  <Ms2ger@igalia.com>
 
         Remove unnecessary copies of PlatformMediaSessionManager::m_sessions
index 569375d..7c06ec5 100644 (file)
@@ -203,7 +203,14 @@ PreviewLoader::~PreviewLoader()
 
 bool PreviewLoader::shouldCreateForMIMEType(const String& mimeType)
 {
-    return [QLPreviewGetSupportedMIMETypesSet() containsObject:mimeType];
+    static std::once_flag onceFlag;
+    static NeverDestroyed<HashSet<String, ASCIICaseInsensitiveHash>> supportedMIMETypes;
+    std::call_once(onceFlag, [] {
+        for (NSString *mimeType in QLPreviewGetSupportedMIMETypesSet())
+            supportedMIMETypes.get().add(mimeType);
+    });
+
+    return supportedMIMETypes.get().contains(mimeType);
 }
 
 std::unique_ptr<PreviewLoader> PreviewLoader::create(ResourceLoader& loader, const ResourceResponse& response)