<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>303803</bug_id>
          
          <creation_ts>2025-12-08 18:53:25 -0800</creation_ts>
          <short_desc>PNG converted to HEIC on file upload seemingly not accepted by image/* wildcard</short_desc>
          <delta_ts>2026-01-08 07:45:39 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Images</component>
          <version>Safari 18</version>
          <rep_platform>All</rep_platform>
          <op_sys>macOS 15</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="janbrasna">gizmo-bobcat6l</reporter>
          <assigned_to name="Karl Dubost">karlcow</assigned_to>
          <cc>gizmo-bobcat6l</cc>
    
    <cc>karlcow</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2164313</commentid>
    <comment_count>0</comment_count>
    <who name="janbrasna">gizmo-bobcat6l</who>
    <bug_when>2025-12-08 18:53:25 -0800</bug_when>
    <thetext>Since Safari 17, uploaded &lt;input type=&quot;file&quot; accept=&quot;image/*,image/heic&quot;&gt; converts PNGs or JPGs to HEIC first before uploading, even though the image/* should be enough for that media types to be accepted without conversion. Explicitly adding HEIC to that list (for historical reasons) does not mean it&apos;s the only or preferred format accepted, but Safari starts converting every other image type to it in such forms.

MRE: https://jsfiddle.net/us1hdpzr/

Simply adding an explicit PNG mime type allows PNGs unconverted: https://jsfiddle.net/gk0b74uc/
(NB: This example still converts JPEGs or GIFs before uploading, for demonstration. This time to PNGs, as that&apos;s the first fully enumerated accept type in the list, so the tempImageNnNNnN.png from other formats is coerced into PNG in this instance.)

For support it doesn&apos;t matter if the PNG is first in the order or not, it can be added well after the HEIC or after the wildcard: https://jsfiddle.net/8spartde/ — what matters in the order however, is what&apos;s the first non-wildcard accept type, to which the other ones get converted. Demonstrated by this order: https://jsfiddle.net/q3op1u6c/ which converts GIFs to JPEGs, being the first in the list.

So the issue is not actually HEIC/HEIF specific per se, as just specifying a wildcard, and a full mime type like this: https://jsfiddle.net/hLxpmt2b/ also reproduces this problem, here coercing everything from GIF to HEIC to a PNG beforehand.

It just seems related to the logic added some time ago to convert HEIC/HEIF files for compatibility reasons to other image formats. But the logic seems ending up too greedy, and doing conversions even in unexpected directions since then?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164318</commentid>
    <comment_count>1</comment_count>
    <who name="janbrasna">gizmo-bobcat6l</who>
    <bug_when>2025-12-08 19:02:47 -0800</bug_when>
    <thetext>Some previous work in that field:
- Bug 213347
- Bug 292041
- Bug 219783

Other reports:
- https://developer.apple.com/forums/thread/743049
- https://core.trac.wordpress.org/ticket/62447
   (explicitly adding the mime due to https://issues.chromium.org/issues/375118901 …)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164331</commentid>
    <comment_count>2</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-12-08 20:45:35 -0800</bug_when>
    <thetext>Different test cases:
The script part is the same in all cases. 

&lt;input type=&quot;file&quot; multiple
  accept=&quot;CONTENT_TYPE_VALUE&quot;
  id=&quot;file&quot;&gt;
&lt;p id=&quot;result&quot;&gt;&lt;/p&gt;
&lt;script&gt;
document.getElementById(&quot;file&quot;).addEventListener(&quot;change&quot;, (ev) =&gt; {
  document.getElementById(&quot;result&quot;).innerHTML = [...ev.target.files]
    .map((file) =&gt; file.name)
    .join(&quot;&lt;br /&gt;&quot;)
})
&lt;/script&gt;

Select A PNG as input


# test case A: https://jsfiddle.net/us1hdpzr/
accept=&quot;image/*, image/heic&quot;

# test case B: https://jsfiddle.net/gk0b74uc/
accept=&quot;image/png, image/*, image/heic&quot;

# test case C: https://jsfiddle.net/8spartde/
accept=&quot;image/heic, image/png, image/*&quot;

# test case D: https://jsfiddle.net/q3op1u6c/
accept=&quot;image/jpeg, image/png, image/*, image/heic&quot;

# test case E: https://jsfiddle.net/hLxpmt2b/
accept=&quot;image/png, image/*&quot;

I&apos;m adding a test case F

# test case F: 
accept=&quot;image/*&quot;




on macOS 26.2

Safari - PNG 
===========
A: tempImagebLRNyk.heic
B: webcompat.png
C: webcompat.png
D: webcompat.png
E: webcompat.png
F: webcompat.png


Firefox - PNG 
=======
A: webcompat.png
B: webcompat.png
C: webcompat.png
D: webcompat.png
E: webcompat.png
F: webcompat.png

Chrome - PNG 
=======
A: webcompat.png
B: webcompat.png
C: webcompat.png
D: webcompat.png
E: webcompat.png
F: webcompat.png


Tested with 
Safari Technology Preview  233          21624.1.3
Firefox Nightly            147.0a1       14725.12.3
Google Chrome Canary       145.0.7569.0  7569.0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164334</commentid>
    <comment_count>3</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-12-08 20:52:20 -0800</bug_when>
    <thetext>Need to dive in the code 
https://searchfox.org/wubkat/rev/904d209b92e989c17e5133a96c75eb75d2941d5a/Source/WebKit/UIProcess/WebPageProxy.cpp#11010-11055</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164358</commentid>
    <comment_count>4</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-12-09 00:34:55 -0800</bug_when>
    <thetext>Oh no the bug is here. 

https://searchfox.org/wubkat/rev/904d209b92e989c17e5133a96c75eb75d2941d5a/Source/WebCore/platform/graphics/cg/ImageUtilitiesCG.cpp#100-114

```
        if (!allowedMIMETypes.contains(WebCore::MIMETypeRegistry::mimeTypeForPath(path))) {
            needsTranscoding = true;
            return path;
        }
```

[&quot;image/*&quot;, &quot;image/heic&quot;].contains(&quot;image/png&quot;), it will add it to the list of files which needs to be transcoded.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164359</commentid>
    <comment_count>5</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-12-09 00:36:26 -0800</bug_when>
    <thetext>&quot;image/*&quot; is treated as a literal string, not a wildcard.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164364</commentid>
    <comment_count>6</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2025-12-09 00:48:57 -0800</bug_when>
    <thetext>&lt;rdar://problem/166124206&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2164365</commentid>
    <comment_count>7</comment_count>
    <who name="Karl Dubost">karlcow</who>
    <bug_when>2025-12-09 00:52:34 -0800</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/55090</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2170285</commentid>
    <comment_count>8</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-01-08 07:45:37 -0800</bug_when>
    <thetext>Committed 305283@main (4a46daaf002f): &lt;https://commits.webkit.org/305283@main&gt;

Reviewed commits have been landed. Closing PR #55090 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>