-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When adding image support for "com.adobe.photoshop-image", also add M…
…IME type "application/x-photoshop" https://bugs.webkit.org/show_bug.cgi?id=260464 rdar://103614570 Reviewed by Said Abou-Hallawa. Mail adds "com.adobe.photoshop-image" as supported type, so that Photoshop images may be viewed as images in emails. At that time, the associated MIME type "image/vnd.adobe.photoshop" also gets added. However when inserting an attachment with file extension "psd", the system infers its MIME type as "application/x-photoshop" instead, which is not supported by default, this prevents psd's from appearing in the Mail editor. So when adding "com.adobe.photoshop-image", the MIME type "application/x-photoshop" gets added as well to correctly show attached psd images. * Source/WebCore/platform/graphics/cg/UTIRegistry.cpp: (WebCore::setAdditionalSupportedImageTypes): * Source/WebCore/platform/network/mac/UTIUtilities.h: * Source/WebCore/platform/network/mac/UTIUtilities.mm: (WebCore::RequiredMIMETypesFromUTI): Note: This 1:M UTI->MIME mapping should be exceedingly rare, so a simple `if` test here is enough. * Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: * Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestUTIRegistry.cpp: Added. (TestWebKitAPI::TEST): Relevant tests for this fix, but also a check to know if one day this fix is not needed anymore or needs an update (e.g., if the platform starts to associate *.psd files with "image/vnd.adobe.photoshop" or another MIME type). * Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestUTIUtilities.cpp: Added. (TestWebKitAPI::TEST): Canonical link: https://commits.webkit.org/267153@main
- Loading branch information
Showing
6 changed files
with
127 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestUTIRegistry.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "WebCore/UTIRegistry.h" | ||
|
||
#include "WebCore/MIMETypeRegistry.h" | ||
#include <wtf/Vector.h> | ||
|
||
namespace TestWebKitAPI { | ||
|
||
using namespace WebCore; | ||
|
||
TEST(UTIRegistry, AdditionalSupportedImageTypesForMailPsd) | ||
{ | ||
EXPECT_FALSE(isSupportedImageType("com.adobe.photoshop-image"_s)); | ||
EXPECT_FALSE(MIMETypeRegistry::isSupportedImageMIMEType("image/vnd.adobe.photoshop"_s)); | ||
EXPECT_FALSE(MIMETypeRegistry::isSupportedImageMIMEType("application/x-photoshop"_s)); | ||
|
||
setAdditionalSupportedImageTypes(Vector { String { "com.adobe.photoshop-image"_s } }); | ||
EXPECT_TRUE(isSupportedImageType("com.adobe.photoshop-image"_s)); | ||
EXPECT_TRUE(MIMETypeRegistry::isSupportedImageMIMEType("image/vnd.adobe.photoshop"_s)); | ||
// If this fails, Mail may not be able to display psd images when editing. | ||
EXPECT_TRUE(MIMETypeRegistry::isSupportedImageMIMEType("application/x-photoshop"_s)); | ||
// If this fails, the special case of "application/x-photoshop" introduced in | ||
// https://bugs.webkit.org/show_bug.cgi?id=260464 should be removed or reworked. | ||
EXPECT_EQ(MIMETypeRegistry::mimeTypeForExtension("psd"_s), "application/x-photoshop"_s); | ||
} | ||
|
||
}; // namespace TestWebKitAPI |
50 changes: 50 additions & 0 deletions
50
Tools/TestWebKitAPI/Tests/WebCore/cocoa/TestUTIUtilities.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2023 Apple Inc. All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
* modification, are permitted provided that the following conditions | ||
* are met: | ||
* 1. Redistributions of source code must retain the above copyright | ||
* notice, this list of conditions and the following disclaimer. | ||
* 2. Redistributions in binary form must reproduce the above copyright | ||
* notice, this list of conditions and the following disclaimer in the | ||
* documentation and/or other materials provided with the distribution. | ||
* | ||
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' | ||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | ||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS | ||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF | ||
* THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "config.h" | ||
#include "WebCore/UTIUtilities.h" | ||
|
||
#include <wtf/HashSet.h> | ||
#include <wtf/text/StringHash.h> | ||
|
||
namespace TestWebKitAPI { | ||
|
||
using namespace WebCore; | ||
|
||
TEST(UTIUtilities, MIMETypeFromUTIForMailPsd) | ||
{ | ||
EXPECT_EQ(MIMETypeFromUTI("com.adobe.photoshop-image"_s), "image/vnd.adobe.photoshop"_s); | ||
} | ||
|
||
TEST(UTIUtilities, RequiredMIMETypesFromUTIForMailPsd) | ||
{ | ||
auto mimeTypes = RequiredMIMETypesFromUTI("com.adobe.photoshop-image"_s); | ||
EXPECT_EQ(mimeTypes.size(), 2u); | ||
EXPECT_TRUE(mimeTypes.contains("image/vnd.adobe.photoshop"_s)); | ||
// If this fails, Mail may not be able to display psd images when editing. | ||
EXPECT_TRUE(mimeTypes.contains("application/x-photoshop"_s)); | ||
} | ||
|
||
}; // namespace TestWebKitAPI |