[wp-trac] [WordPress Trac] #37608: Undefined index: extension in class-wp-image-editor.php

WordPress Trac noreply at wordpress.org
Fri Sep 16 18:24:22 UTC 2016


#37608: Undefined index: extension in class-wp-image-editor.php
--------------------------------------+-----------------------------
 Reporter:  JaworskiMatt              |       Owner:  wonderboymusic
     Type:  defect (bug)              |      Status:  reopened
 Priority:  normal                    |   Milestone:  4.7
Component:  Media                     |     Version:  2.5
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:
--------------------------------------+-----------------------------

Comment (by JanR):

 Today I noticed something relevant -I think- in the Media Library: strange
 behavior when a file name has a `%` sign in it. In a very extreme case,
 double extension it and name your file `filename.html%00.png`

 On my dev site: after uploading, it has the following Attachment Details:

 WordPress trunk

     File name: filename.html00.png
     File type: image/png
     URL https://www.vanilla-wp.org/wp-
 content/uploads/2016/09/filename.html00.png
     Title: filename-html%00-png

 and the View attachment URL goes to `about:blank` in Chrome. The HTML code
 for the link has an additional `/`:

     `<a class="view-attachment" href="https://www.vanilla-wp.org/filename-
 html%00-png/">View attachment page</a>`

 Firefox does not have this behavior and the link is: `https://www.vanilla-
 wp.org/filename-html%00-png/` resulting in a HTTP 400 Bad Request -
 Invalid URL error. (on IIS).

 When I remove the double extension, the upload gives me an error message:

     filename.html%00 This file type is not allowed. Please try another.


 In WordPress 4.6.1 (had to remove this test URL):

     File name: filename.html00.png
     File type: image/png
     URL http://www.vanilla-wp.org/test-4.6/wp-
 content/uploads/2016/09/filename.html00.png
     Title: filename-html%00

 After talking to @joemcgill on Slack, I tested WordPress trunk with
 https://core.trac.wordpress.org/attachment/ticket/37989/37989.3.diff
 applied:

     File name: filename.html00.png
     File type: image/png
     URL https://www.vanilla-wp.org/wp-
 content/uploads/2016/09/filename.html00.png
     Title: filename.html

 The View attachment URL issue is fixed with the applied diff.

 Now if you asked me what correct behavior is, I don't know. But I don't
 think it's a good idea to base the file type from it's last extension (in
 case of a double extension).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37608#comment:13>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list