Bug 244666

Summary: Drag / drop file conversion renames the files to "tempImage[A-Za-z0-9]{6}" for some mime-types
Product: WebKit Reporter: Flavian Hautbois <f.hautbois>
Component: ImagesAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Major CC: f.hautbois, karlcow, sabouhallawa, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: BrowserCompat, InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Flavian Hautbois 2022-09-01 06:49:17 PDT
# Overview

This bug was likely introduced by bug 212482.
There is a bug in this implementation where at least files with extensions .dng (image/x-adobe-dng , image/x-canon-cr2) and .cr2 keep a temporary name "tempImage[A-Za-z0-9]{6}". This name is only [attributed in ImageUtiliesCG.cpp](https://github.com/WebKit/WebKit/blob/cb8ffd4609c68a076d701b85b0c41d3743af5a0c/Source/WebCore/platform/graphics/cg/ImageUtilitiesCG.cpp#L72).

# Steps to reproduce

1. Open this link with Safari: https://jsfiddle.net/6nzs5u1a/
2. Download `sample1.cr2` from https://filesamples.com/formats/cr2
3. Drag and drop this file into the input field of the jsfiddle

# Actual result

Observe that the `filename` element turns to `tempImageXXXXX.png`.

# Expected result

Observe that the `filename` element turns to `sample1.png`.
Notes: 
- When using HEIC as an input format, the `filename` reverts to the original file name with a new extension
- When using .DNG files, the unexpected behaviour with tempImage still happens.

# Build Date & Hardware

Safari Version 15.4 (17613.1.17.1.13) on macOS 12.3.1

# Additional Builds and Platforms

It does not happen on Google Chrome 104

# Additional enquiries

I suspect that after the temporary file is created, it must be renamed to the previous name but with the right file extension. I haven't managed to find the line of code that does this, but I think this is where the bug happens.
Comment 1 Flavian Hautbois 2022-09-01 06:50:30 PDT
Additionally, I've made a video of the reproduction steps: https://youtu.be/6AsmSbjvc6c
Comment 2 Flavian Hautbois 2022-09-01 07:05:23 PDT
There is also one Stackoverflow question about this bug: https://stackoverflow.com/a/73570703/1074116

It appears that files other than images are attempted to be converted, and end up with this tempImage name.
Comment 3 Radar WebKit Bug Importer 2022-09-08 06:50:21 PDT
<rdar://problem/99696035>