Bug 171077 - Whitelist supported image MIME types
Summary: Whitelist supported image MIME types
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks: 170700
  Show dependency treegraph
 
Reported: 2017-04-20 14:31 PDT by Said Abou-Hallawa
Modified: 2017-04-24 17:14 PDT (History)
7 users (show)

See Also:


Attachments
Patch (15.20 KB, patch)
2017-04-20 14:36 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (13.60 KB, patch)
2017-04-20 14:56 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews116 for mac-elcapitan (1.53 MB, application/zip)
2017-04-20 15:44 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews103 for mac-elcapitan (723.91 KB, application/zip)
2017-04-20 15:45 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (1.09 MB, application/zip)
2017-04-20 15:51 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews125 for ios-simulator-wk2 (57.76 MB, application/zip)
2017-04-20 16:20 PDT, Build Bot
no flags Details
Patch (13.58 KB, patch)
2017-04-20 16:52 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (14.06 KB, patch)
2017-04-20 18:52 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews122 for ios-simulator-wk2 (762.08 KB, application/zip)
2017-04-20 22:07 PDT, Build Bot
no flags Details
Patch (14.18 KB, patch)
2017-04-21 08:55 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (13.67 KB, patch)
2017-04-21 11:20 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (13.12 KB, patch)
2017-04-21 12:06 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-elcapitan-wk2 (1.83 MB, application/zip)
2017-04-21 13:01 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews112 for mac-elcapitan (1.86 MB, application/zip)
2017-04-21 13:04 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews102 for mac-elcapitan (1.04 MB, application/zip)
2017-04-21 13:05 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews123 for ios-simulator-wk2 (53.97 MB, application/zip)
2017-04-21 13:59 PDT, Build Bot
no flags Details
Patch (12.54 KB, patch)
2017-04-21 14:26 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (12.52 KB, patch)
2017-04-21 15:14 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (11.58 KB, patch)
2017-04-21 16:05 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (11.52 KB, patch)
2017-04-21 16:29 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (11.48 KB, patch)
2017-04-21 16:39 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (12.01 KB, patch)
2017-04-21 18:12 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (12.01 KB, patch)
2017-04-24 14:46 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Patch (12.11 KB, patch)
2017-04-24 16:32 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2017-04-20 14:31:48 PDT
This API should return the UTIs of the images instead of MIME types because some of UTIs do not have corresponding MIME types.
Comment 1 Said Abou-Hallawa 2017-04-20 14:36:35 PDT
Created attachment 307637 [details]
Patch
Comment 2 Said Abou-Hallawa 2017-04-20 14:56:21 PDT
Created attachment 307641 [details]
Patch
Comment 3 Radar WebKit Bug Importer 2017-04-20 15:11:10 PDT
<rdar://problem/31743803>
Comment 4 Build Bot 2017-04-20 15:44:38 PDT
Comment on attachment 307641 [details]
Patch

Attachment 307641 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3572422

Number of test failures exceeded the failure limit.
Comment 5 Build Bot 2017-04-20 15:44:39 PDT
Created attachment 307650 [details]
Archive of layout-test-results from ews116 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews116  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 6 Build Bot 2017-04-20 15:45:55 PDT
Comment on attachment 307641 [details]
Patch

Attachment 307641 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3572470

Number of test failures exceeded the failure limit.
Comment 7 Build Bot 2017-04-20 15:45:56 PDT
Created attachment 307651 [details]
Archive of layout-test-results from ews103 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 8 Build Bot 2017-04-20 15:51:22 PDT
Comment on attachment 307641 [details]
Patch

Attachment 307641 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3572490

Number of test failures exceeded the failure limit.
Comment 9 Build Bot 2017-04-20 15:51:23 PDT
Created attachment 307653 [details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 10 Build Bot 2017-04-20 16:20:05 PDT
Comment on attachment 307641 [details]
Patch

Attachment 307641 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3572469

Number of test failures exceeded the failure limit.
Comment 11 Build Bot 2017-04-20 16:20:11 PDT
Created attachment 307657 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 12 Said Abou-Hallawa 2017-04-20 16:52:48 PDT
Created attachment 307661 [details]
Patch
Comment 13 Said Abou-Hallawa 2017-04-20 18:52:22 PDT
Created attachment 307674 [details]
Patch
Comment 14 Build Bot 2017-04-20 22:07:26 PDT
Comment on attachment 307674 [details]
Patch

Attachment 307674 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3573990

New failing tests:
http/tests/local/blob/send-hybrid-blob-using-open-panel.html
Comment 15 Build Bot 2017-04-20 22:07:27 PDT
Created attachment 307691 [details]
Archive of layout-test-results from ews122 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews122  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 16 Simon Fraser (smfr) 2017-04-21 03:58:48 PDT
Comment on attachment 307674 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307674&action=review

> Source/WebCore/ChangeLog:3
> +        Add an API to return a list of the WebKit supported image formats

I don' think this is API, right? It's not exposed through WKWebView?
Comment 17 Said Abou-Hallawa 2017-04-21 08:55:21 PDT
Created attachment 307734 [details]
Patch
Comment 18 Tim Horton 2017-04-21 10:58:02 PDT
Comment on attachment 307734 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307734&action=review

> Source/WebCore/platform/ImageTypeIdentifierRegistry.cpp:27
> +#include "ImageTypeIdentifierRegistry.h"

I think we should make this generic and specific, and similar to MIMETypeRegistry: "UTIRegistry", so that in the future when we want to do the same for e.g. video or audio or document types we can, without renaming!

Also, it should probably be USE(CG)-specific, UTIs are an Apple concept.

> Source/WebCore/platform/ImageTypeIdentifierRegistry.cpp:48
> +    static NeverDestroyed<HashSet<String>> unsupportedTypetypeIdentifiers(std::initializer_list<String> {

"unsupportedTypetypeIdentifiers" -- type type?

> Source/WebCore/platform/ImageTypeIdentifierRegistry.cpp:88
> +    return unsupportedTypetypeIdentifiers.get().contains(typeIdentifier);

This looks like a blacklist to me, not a whitelist; what's to guarantee that new versions of CG don't add support for new image formats that we don't want to expose to the web?
Comment 19 Said Abou-Hallawa 2017-04-21 11:20:40 PDT
Created attachment 307756 [details]
Patch
Comment 20 Said Abou-Hallawa 2017-04-21 12:06:34 PDT
Created attachment 307768 [details]
Patch
Comment 21 Said Abou-Hallawa 2017-04-21 12:17:27 PDT
Comment on attachment 307734 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307734&action=review

>> Source/WebCore/platform/ImageTypeIdentifierRegistry.cpp:27
>> +#include "ImageTypeIdentifierRegistry.h"
> 
> I think we should make this generic and specific, and similar to MIMETypeRegistry: "UTIRegistry", so that in the future when we want to do the same for e.g. video or audio or document types we can, without renaming!
> 
> Also, it should probably be USE(CG)-specific, UTIs are an Apple concept.

The name is fixed. Regarding making the file USE(CG)-specific, I do not think I can do that. Some of the supported image formats don't have corresponding MIME types, so CG has to use the UTI's. For none-CG platforms I made them return a UTI, please see the https://bugs.webkit.org/show_bug.cgi?id=171042. And the plan is use isSupportedImageUTI() on all platforms.

>> Source/WebCore/platform/ImageTypeIdentifierRegistry.cpp:48
>> +    static NeverDestroyed<HashSet<String>> unsupportedTypetypeIdentifiers(std::initializer_list<String> {
> 
> "unsupportedTypetypeIdentifiers" -- type type?

Fixed.

>> Source/WebCore/platform/ImageTypeIdentifierRegistry.cpp:88
>> +    return unsupportedTypetypeIdentifiers.get().contains(typeIdentifier);
> 
> This looks like a blacklist to me, not a whitelist; what's to guarantee that new versions of CG don't add support for new image formats that we don't want to expose to the web?

Fixed.
Comment 22 Build Bot 2017-04-21 13:01:39 PDT
Comment on attachment 307768 [details]
Patch

Attachment 307768 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/3577828

Number of test failures exceeded the failure limit.
Comment 23 Build Bot 2017-04-21 13:01:40 PDT
Created attachment 307778 [details]
Archive of layout-test-results from ews107 for mac-elcapitan-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-elcapitan-wk2  Platform: Mac OS X 10.11.6
Comment 24 Build Bot 2017-04-21 13:04:56 PDT
Comment on attachment 307768 [details]
Patch

Attachment 307768 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3577819

Number of test failures exceeded the failure limit.
Comment 25 Build Bot 2017-04-21 13:04:58 PDT
Created attachment 307780 [details]
Archive of layout-test-results from ews112 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews112  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 26 Build Bot 2017-04-21 13:05:09 PDT
Comment on attachment 307768 [details]
Patch

Attachment 307768 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/3577851

Number of test failures exceeded the failure limit.
Comment 27 Build Bot 2017-04-21 13:05:11 PDT
Created attachment 307781 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 28 Build Bot 2017-04-21 13:59:32 PDT
Comment on attachment 307768 [details]
Patch

Attachment 307768 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/3578013

Number of test failures exceeded the failure limit.
Comment 29 Build Bot 2017-04-21 13:59:34 PDT
Created attachment 307794 [details]
Archive of layout-test-results from ews123 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews123  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 30 Said Abou-Hallawa 2017-04-21 14:26:49 PDT
Created attachment 307809 [details]
Patch
Comment 31 Said Abou-Hallawa 2017-04-21 15:14:47 PDT
Created attachment 307815 [details]
Patch
Comment 32 Tim Horton 2017-04-21 15:21:03 PDT
Comment on attachment 307815 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307815&action=review

> Source/WebCore/platform/UTIRegistry.cpp:46
> +static void initializeWhitelistImageUTIs(HashSet<String>& whitelistImageUTIs)

If this returns the HashSet instead, then you can...

> Source/WebCore/platform/UTIRegistry.cpp:88
> +    static NeverDestroyed<HashSet<String>> s_whitelistImageUTIs;

... just do an = initializeWhitelistImageUTIs(); here...

> Source/WebCore/platform/UTIRegistry.cpp:91
> +    if (!s_whitelistImageUTIs.get().size())
> +        initializeWhitelistImageUTIs(s_whitelistImageUTIs.get());

allowing you to get rid of this entirely.
Comment 33 Tim Horton 2017-04-21 15:23:16 PDT
Comment on attachment 307815 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307815&action=review

> Source/WebCore/platform/UTIRegistry.cpp:81
> +    // Assume that all implementations at least support the following standard
> +    // image types:
> +    whitelistImageUTIs = std::initializer_list<String> {
> +        "public.jpeg",
> +        "public.png",
> +        "com.compuserve.gif",
> +        "com.microsoft.bmp",
> +        "com.microsoft.ico",
> +#if USE(WEBP)
> +        "com.google.webp"
> +#endif

This is only called from USE(CG) code, so I think you should just delete this and make the whole thing guarded by USE(CG).

> Source/WebCore/platform/UTIRegistry.h:33
> +HashSet<String>& whitelistImageUTIs();

allowedImageUTIs(), I think.
Comment 34 Said Abou-Hallawa 2017-04-21 16:05:21 PDT
Created attachment 307822 [details]
Patch
Comment 35 Tim Horton 2017-04-21 16:09:14 PDT
Comment on attachment 307822 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307822&action=review

> Source/WebCore/ChangeLog:14
> +        * platform/graphics/cg/UTIRegistryCG.cpp: Added.

Not likely that there will ever be a non-CG version of this, so you could just leave the CG off (usually we add the suffix if it's the CG parts of a cross-platform class).
Comment 36 Said Abou-Hallawa 2017-04-21 16:29:38 PDT
Created attachment 307834 [details]
Patch
Comment 37 Said Abou-Hallawa 2017-04-21 16:39:26 PDT
Created attachment 307836 [details]
Patch
Comment 38 Said Abou-Hallawa 2017-04-21 18:12:47 PDT
Created attachment 307857 [details]
Patch
Comment 39 Said Abou-Hallawa 2017-04-24 14:46:44 PDT
Created attachment 308013 [details]
Patch
Comment 40 Said Abou-Hallawa 2017-04-24 14:47:46 PDT
Comment on attachment 307857 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=307857&action=review

> Source/WebCore/ChangeLog:15
> +        * platform/graphics/cg/UTIRegistryCG.cpp: Added.

This entry is wrong. The file UTIRegistryCG.cpp was renamed to UTIRegistry.cpp. I will submit an update.
Comment 41 Tim Horton 2017-04-24 15:58:14 PDT
Comment on attachment 308013 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=308013&action=review

> Source/WebCore/ChangeLog:9
> +        WebKit should support only a whitelist image formats. WebKit will not support new
> +        image formats till they get broader industry adoption.

"should support only whitelisted image formats".

Also, this isn't a generic WebKit policy (obviously), this is about CG ports. I think you should drop the second sentence, too, since even that isn't a guarantee of support, of course. Maybe write something helpful about the code change you made instead?
Comment 42 Said Abou-Hallawa 2017-04-24 16:32:05 PDT
Created attachment 308022 [details]
Patch
Comment 43 WebKit Commit Bot 2017-04-24 17:14:37 PDT
Comment on attachment 308022 [details]
Patch

Clearing flags on attachment: 308022

Committed r215706: <http://trac.webkit.org/changeset/215706>
Comment 44 WebKit Commit Bot 2017-04-24 17:14:39 PDT
All reviewed patches have been landed.  Closing bug.