File extension not recognised correctly

Created on 28 May 2021, over 3 years ago
Updated 27 May 2024, 7 months ago

I noticed some 404 Not Found errors on the /admin/node/add/page when I added the CKEditor to one of the text fields on the content type.

After a bit of debugging I found the issue was in the FileUrlGenerator.php line 159 (https://git.drupalcode.org/project/cdn/-/blob/8.x-3.x/src/File/FileUrlGe...)

$file_extension = mb_strtolower(pathinfo($uri, PATHINFO_EXTENSION));

In itself the code above is fine but when the $uri variable has values such as "core/modules/ckeditor/css/ckeditor-iframe.css?qtrcb9" it fails to detect the extension of the file correctly. This can be verified on the command line like this:

$ php -r 'print "This is the detected extension: " . pathinfo("core/modules/ckeditor/css/ckeditor-iframe.css?qtrcb9", PATHINFO_EXTENSION) . "\n";'
This is the detected extension: css?qtrcb9

The proposed enhancement would be to remove the trailing "query string" part from the URI when detecting the extension. Patch to be provided in below comments.

🐛 Bug report
Status

Closed: duplicate

Version

3.0

Component

Code

Created by

🇫🇮Finland TomiMikola

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024