My favorites | Sign in
Logo
             
New issue | Search
for
| Advanced search | Search tips
Issue 7849: Dragging files to desktop will get a wrong file name
10 people starred this issue and may be notified of changes. Back to list
 
Reported by adonnod, Feb 19, 2009
Chrome Version       : 2.0.164.0 (9941)
URLs (if applicable) :
Other browsers tested:
Add OK or FAIL after other browsers where you have tested this issue:
Safari 3:
    Firefox 3: OK
         IE 7: OK

What steps will reproduce the problem?
1. dragging a file, usually a image with a hyperlink that link to another 
page/file, to your desktop. 
For example, try to drag the logo of Google code at the left-top corner. 
The image name is "code_sm.png" and has a link to "http://code.google.com/" 
2. The file you dragged will get a wrong name based on its hyperlink, 
instead of its own name.
The name of logo you dragged is "google.png"
3.

What is the expected result?
file should get its original name

What happens instead?
wrong name

Please provide any additional information below. Attach a screenshot if 
possible.


Comment 1 by dhhwai, Feb 19, 2009
[Confirmed] in 2.0.164.0.

This worked properly before.  Add label: Regression
Comment 2 by mberkow...@chromium.org, Feb 19, 2009
What I'm seeing is that the "alt text", if any, becomes the name of the dropped
image.  If there is no "alt text", the filename of the image becomes the name of the
dropped image.

So, for example:

<img src="hills.jpg" alt="This is the alt text">
The dropped image is named "This is the alt text.jpg".

<img src="hills.jpg">
The dropped image is named "hills.jpg".

Is this what you're seeing?

Labels: FeedbackRequired
Comment 3 by dhhwai, Feb 19, 2009
Yes, it seems like the "alt" text becomes the dropped filename.... which is quite simply 
the wrong thing to do!  And this also applies to the "title" attribute in case the <img> 
tag has a "title" attribute.  Do *not* use either of these attribute values for the dropped 
filename no matter if they exist or not.

And this applies no matter if the loaded resource is a simple filename or a complex request 
query.  For example:
  someimage.jpg
  someimage.jpg?parm1=val1&parm2=val2
  somescript.php?parm1=val1&parm2=val2 (that returns something that is an image MIME type)

all should the dropped with their _resource names_.  In the second and third cases above, 
it will probably result in a generated filename without the proper extension and not 
directly openable in the OS, but that is _to be expected_.

Regardless, you cannot use any of the "alt" or "title" values to generate the dropped 
filename.
Comment 5 by dhhwai, Feb 19, 2009
Dropping the image should use the same filename as right-click > Save Image As, which 
is to use the filename of the resource.  See  Issue 7023 
Comment 6 by mberkow...@chromium.org, Feb 19, 2009
OK, confirmed. Thanks to adonnod and dhhwai.
Status: Untriaged
Labels: -FeedbackRequired Regression
Comment 7 by jon@chromium.org, Mar 26, 2009
(No comment was entered for this change.)
Status: Available
Labels: -Pri-2 -Area-Misc Pri-1 Area-BrowserUI Size-Small Mstone-2.0
Comment 8 by deanm@chromium.org, Mar 27, 2009
Sounds like some stuff Adam has worked on.
Cc: aba...@chromium.org
Comment 9 by m...@chromium.org, Mar 27, 2009
I'll see if I can fix it...
Status: Assigned
Owner: m...@chromium.org
Comment 10 by m...@chromium.org, Mar 27, 2009
This is a WebKit issue... Safari 4 suffers from the same thing...

Makes sense since the code handling the drop is in WebKit's Node event dispatch code.

I couldn't find a bug for this on bugs.webkit.org, so I'll create one and add a 
double-link to and from this one...


Comment 11 by m...@chromium.org, Mar 27, 2009
Here's the WebKit bug link: https://bugs.webkit.org/show_bug.cgi?id=24887


Comment 12 by m...@chromium.org, Mar 27, 2009
Weird... I found the code setting the value, and it is on the platform/chromium side...

Seems like Safari 4.0 foe Windows made the same mistake we did then (or vice versa) :-) The Mac version does the right 
thing BTW. The win version do the same mistake in the platform/win version of the code (though the code is different, the 
end result is the same). I'll update the WebKit bug with the relevant info for them.

Here's the info for us:

in third_party\WebKit\WebCore\platform\chromium\ClipboardChromium.cpp
ClipboardChromium::declareAndWriteDragImage() calls writeImageToDataObject()
This static function has the following code:
    // Determine the filename for the file contents of the image.  We try to
    // use the alt tag if one exists, otherwise we fall back on the suggested
    // filename in the http header, and finally we resort to using the filename
    // in the URL.
    String extension = MIMETypeRegistry::getPreferredExtensionForMIMEType(
        cachedImage->response().mimeType());
    dataObject->fileExtension = extension.isEmpty() ? "" : "." + extension;
    String title = element->getAttribute(altAttr);
    if (title.isEmpty())
        title = cachedImage->response().suggestedFilename();

    title = ClipboardChromium::validateFileName(title, dataObject);
    dataObject->fileContentFilename = title + dataObject->fileExtension;

And this is why we get the <alt> text instead of the actually filename from the URL as when we save image and as we see as 
a behavior of Safari 4 on Mac. I'll check with the people who wrote the code above to see if there is a good reason for 
this.


Comment 13 by m...@chromium.org, Mar 27, 2009
I have a fix coming, will get it reviewed by tc who seem to be the original author...
Status: Started
Comment 14 by m...@chromium.org, Mar 30, 2009
(No comment was entered for this change.)
Status: Upstream
Comment 15 by m...@chromium.org, Mar 30, 2009
I have a fix in the pipeline on the WebKit side:
https://bugs.webkit.org/show_bug.cgi?id=24887

Comment 16 by jon@chromium.org, Jun 15, 2009
Moving to mstone 3 from an older milestone.  Need to triage.
Status: Untriaged
Labels: Mstone-3
Comment 17 by jon@chromium.org, Jun 15, 2009
Moving to milestone 3 from an older milestone.  Need to triage.
Comment 18 by laforge@chromium.org, Jun 16, 2009
Is there a good way to come up with a regression test for this, pref not a UI unit 
test.
Status: Assigned
Owner: aba...@chromium.org
Cc: -aba...@chromium.org m...@chromium.org
Comment 19 by laforge@chromium.org, Jul 07, 2009
This seems like a webkit bug.
Owner: dglaz...@chromium.org
Cc: aba...@chromium.org
Labels: -Area-BrowserUI Area-WebKit
Comment 20 by progame, Jul 15, 2009
related issue: Issue 16318
Comment 21 by dglazkov@chromium.org, Jul 17, 2009
Dumi, I thought you were somewhere in whereabouts of this code w/HTML5 database file 
handling. Can you take a look?
Owner: d...@chromium.org
Comment 22 by mal.chromium, Jul 20, 2009
(No comment was entered for this change.)
Labels: BugReview
Comment 23 by darin@chromium.org, Jul 20, 2009
(No comment was entered for this change.)
Cc: s...@chromium.org
Comment 24 by mal.chromium, Jul 20, 2009
(No comment was entered for this change.)
Owner: s...@chromium.org
Comment 25 by snej@chromium.org, Jul 20, 2009
Looking at the WebKit bug, Marc-André Decoste had a fix almost ready but then disappeared in mid-April.
His fix looks good, but it was pointed out that it should go into shared code so that all platforms can use it.
I'll pick it up and start working on it.
Comment 26 by jon@chromium.org, Aug 03, 2009
Jens, have you made progress on this?
Comment 27 by snej@chromium.org, Aug 03, 2009
I was making progress, but have been on vacation all last week. Back now, though.
Comment 28 by snej@chromium.org, Aug 04, 2009
FYI, I've just submitted a new patch over at the WebKit bug report.
Comment 31 by jon@chromium.org, Aug 10, 2009
Changing the status to Upstream because Jens is working his way through the review 
process on his patch.  This fix touches a lot of interesting edge cases and we have a 
bunch of patch revisions.  Still need a test for this to be accepted into WebKit.

As we would not block the 3.0 beta release for this I am moving it to mstone-4.  
However the sooner we get this fix the better.  It would be great to get it into 3.0.
Status: Upstream
Labels: -Mstone-3 -BugReview Mstone-4
Comment 32 by snej@chromium.org, Aug 17, 2009
Status: WebKit reviewers required a test case. Specifics of drag-and-drop API on Mac OS make writing a test for 
this nearly impossible without putting lots of hacks into WebKit, so we compromised on requiring a Windows 
test.
I've been bringing up a Windows dev environment and building WebKit on it. Unfortunately the first thing I 
discovered is that all dragging on Windows is currently broken: dragging anything inside a web view causes a 
crash. This was reported a month ago as 27332 but no one seems to have investigated it yet. That pretty much 
stymies me from writing any test cases until that bug is fixed.
Comment 33 by karen@chromium.org, Sep 24, 2009
does this mean this won't be resolved for Milestone 4? What's the next step here?
Comment 34 by snej@chromium.org, Sep 24, 2009
I think it's pretty much stuck until someone fixes drag-n-drop for Windows WebKit (not Chromium).
Comment 35 by dglazkov@chromium.org, Nov 06, 2009
Is this moving now?
Comment 36 by dglazkov@chromium.org, Nov 10, 2009
(No comment was entered for this change.)
Labels: -Mstone-4 Mstone-5
Sign in to add a comment