Shape\Drawing\File : Name an image file whose path does not name itself - #922
Open
dkulyk wants to merge 1 commit into
Open
Shape\Drawing\File : Name an image file whose path does not name itself#922dkulyk wants to merge 1 commit into
dkulyk wants to merge 1 commit into
Conversation
dkulyk
force-pushed
the
fix/extensionless-image
branch
2 times, most recently
from
August 22, 2026 19:01
9de08f5 to
212105d
Compare
Progi1984
approved these changes
Aug 23, 2026
`getExtension()` asks `pathinfo()` and nothing else, so a path carrying no extension answers with an empty string. `getIndexedFilename()` then builds `logo1.` -- a media part ending in a bare dot, which the writers register under no content type at all. The bytes know what the name does not: `getimagesizefromstring()` already backs `getMimeType()` a few lines above, and its type constant converts straight to an extension. The lookup happens only when `pathinfo()` came back empty and the file is there to be read, so a path with an extension costs exactly what it did before -- no file access. An extensionless SVG stays extensionless: it has no pixel dimensions for `getimagesize()` to report, and there is nothing else in the file this decision could rest on.
dkulyk
force-pushed
the
fix/extensionless-image
branch
from
August 23, 2026 12:08
212105d to
077f0f0
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #603.
Description
What is wrong
Shape\Drawing\File::getExtension()derives the extension from the path alone:A path is free to carry no extension — an upload stored under its hash, a file from
tempnam(), an image served from a route — and then the answer is''.getIndexedFilename()builds the name of the media part out of it, so the part is calledlogo1., ending in a bare dot. Both writers register content types by extension, so that part is written under none.The change
The contents say what the name does not, and the same call already backs
getMimeType()a few lines below:It runs only when
pathinfo()came back empty and the file exists, so a path that has an extension costs exactly what it cost before — no file is opened.What it does not do
An extensionless SVG stays extensionless.
getimagesizefromstring()reports nothing for it, and there is nothing else in the file for the decision to rest on. Neighbouring reports #741 and #819 are about the same family of images-loaded-from-content problems and are not touched here.Checklist: