Opened 2 years ago
Closed 7 months ago
#17814 closed defect (bug) (fixed)
wp_load_image() attempts to load directories
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Priority: | normal | Milestone: | 3.5 |
| Component: | Media | Version: | 3.1.3 |
| Severity: | minor | Keywords: | has-patch |
| Cc: |
Description
The wp_load_image() function in /wp-includes/media.php does a file_exists() check on the $file parameter, but that will return TRUE for both files and directories. There is no check to make sure $file is actually a file instead of a directory.
Attachments (5)
Change History (14)
comment:1
benkulbertis
— 2 years ago
- Keywords has-patch added
benkulbertis
— 2 years ago
comment:2
scribu
— 2 years ago
- Component changed from General to Media
- Milestone changed from Awaiting Review to Future Release
comment:3
nacin
— 11 months ago
We can likely combine this into the ! file_exists() check above it, and use the same string.
SergeyBiryukov
— 11 months ago
comment:4
SergeyBiryukov
— 11 months ago
- Milestone changed from Future Release to 3.5
comment:5
DH-Shredder
— 9 months ago
Updated patch to include WP_Image_Editor, and the file-name change for wp_load_image (since the function is now deprecated).
Related: #6821
comment:6
follow-up:
↓ 7
scribu
— 9 months ago
- Summary changed from wp_load_image() to wp_load_image() attempts to load directories
Couldn't we just replace the file_exists() check with is_file() instead of calling both?
comment:7
in reply to:
↑ 6
DH-Shredder
— 9 months ago
Replying to scribu:
Couldn't we just replace the file_exists() check with is_file() instead of calling both?
You're right, looks like we can!
Went ahead and updated the patch. Will write up a quick unit test for this later today, if no-one else gets to it first.
comment:8
DH-Shredder
— 9 months ago
Initial unit test attached. At the moment, errors upon wp_load_image() failure. Going to see if there's a better way to do this.
added is_file check to wp_load_image()