Opened 13 years ago
Closed 12 years ago
#17814 closed defect (bug) (fixed)
wp_load_image() attempts to load directories
Reported by: | primehalo | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | minor | Version: | 3.1.3 |
Component: | Media | Keywords: | has-patch |
Focuses: | 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)
#2
@
13 years ago
- Component changed from General to Media
- Milestone changed from Awaiting Review to Future Release
#3
@
12 years ago
We can likely combine this into the ! file_exists() check above it, and use the same string.
#5
@
12 years 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
#6
follow-up:
↓ 7
@
12 years 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?
#7
in reply to:
↑ 6
@
12 years 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.
#8
@
12 years 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()