Opened 19 years ago
Closed 19 years ago
#6294 closed defect (bug) (fixed)
Uploading media file with same sanitized filename as existing file will overwrite existing file.
| Reported by: | markjaquith | Owned by: | neodude |
|---|---|---|---|
| Priority: | highest omg bbq | Milestone: | 2.5 |
| Component: | Administration | Version: | 2.5 |
| Severity: | blocker | Keywords: | has-patch needs-testing |
| Cc: | Focuses: |
Description
- Upload "test.png" with dimensions X1xY1
- Upload a different file that is also named "test.png" with dimensions X2xY2
The second test.png will overwrite the first, although the first will keep its dimensions of X1xY1, so it will be squished or stretched out.
Blocker, because someone your original file is GONE without any warning.
Desired outcome: test-N.jpg where N is an integer that increments as high as it needs to go to avoid overwriting an existing file.
Attachments (2)
Change History (5)
#2
@
19 years ago
- Cc added
- Keywords has-patch needs-testing added
functions.php-r7414.diff fixes:
- edge case: failed to handle a file named '.ext'
- sanitize_title_with_dashes called too late, which is, AFAIK, the cause of this bug
- with s_t_w_d moved up, the # and \ checks are redundant, since s_t_w_d does s/[%a-z0-9 _-] anyway
I tested two different files named test%test.png and test%%test.png, which correctly gives testtest.png and testtest1.png respectively.
The unit tests cover pretty much all of wp_unique_filename, but only vaguely common bits of sanitize_title_with_dashes. The latter function is very complex to write test cases completely for, so I thought I'd save my time.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
I think I narrowed it down. I'm writing the test cases now, will put that and patch up asap.