Bug 172073 - Drupal JS file uploads don't work
Summary: Drupal JS file uploads don't work
Status: RESOLVED FIXED
Alias: None
Product: konqueror
Classification: Unclassified
Component: khtml (show other bugs)
Version: 4.1.1
Platform: Ubuntu Packages Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: Konqueror Developers
URL: http://head.petsovits.at/node/1/edit
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-03 12:37 UTC by Jakob Petsovits
Modified: 2008-10-27 19:28 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakob Petsovits 2008-10-03 12:37:16 UTC
Since Drupal 6.x, JavaScript-powered file uploads don't work in Drupal. This happens with core Drupal as well as extension modules like filefield or imagefield, and works with several other browsers. I set up a Drupal HEAD test site for you, drop me a mail if you think you need an SSH account on the server too.

Steps to reproduce:
1. Make sure JavaScript is enabled. (It works with JavaScript disabled, and also works if you just press "Save" instead of first doing "Attach".)
2. Go to http://head.petsovits.at/node/1/edit and log in with "khtml-hackerz" as username and the codename for KJS's new bytecode interpreter as password (lowercase). The steps to reproduce are present there as well :)
3. Extend the "File attachments" field set below.
4. Select any file in a format given in the extension list.
5. Press "Attach" and witness Konqueror stalling the upload. The file isn't even sent to the server in the first place, so you can't really clutter the files directory.

Doing the same with Firefox and other browsers works, and a fix for this would *really* be nice as it affects all Drupal versions from 6.x on (which correlates to a large amount of sites).
Comment 1 Maksim Orlovich 2008-10-03 16:13:34 UTC
Many thanks for the report and the test site. Will take a look. (Though I need to dig out my patch for auto-reindenting sources first, since jQuery is the release version..)

Comment 2 Maksim Orlovich 2008-10-03 17:22:02 UTC
Actually, um, any chance you could replace /misc/jquery.js?4
with this version:
http://code.google.com/p/jqueryjs/downloads/detail?name=jquery-1.2.6.js

...my debugger fanciness seems not to be fancy enough for something this compressed

Thanks again for going to such length to help us fix this.
Comment 3 Jakob Petsovits 2008-10-03 20:54:10 UTC
Oops. Er, sure. I also replaced jquery.form.js with the unpacked version [1], just in case. (All .js files should be plaintext now.)

Setting this stuff up is not so much work either, I'm doing Drupal development anyways :P
Thanks to YOU for taking this stuff on and saving me from Firefox and other non-integrated browsers!

[1] http://dev.jquery.com/browser/trunk/plugins/form/jquery.form.js?rev=3767
Comment 4 Maksim Orlovich 2008-10-05 02:48:04 UTC
Thanks. Workaround: disabling popup blocking (!). The code seem to submit the form into a hidden iframe; (I think I had tried to debug something like this before). Investigating further.

[Also seems to be possible to trigger a konqueror crash, which will be nice to fix, too]
Comment 5 Maksim Orlovich 2008-10-05 03:53:25 UTC
The following is a candidate fix, but needs further thought, since some of the code involved I am not familiar with.

(P.S. With respect to the other Drupal report, from the description it's likely that the cause may be an another bug the fix for which I have pending, so I'll look at that after that fix is finalized, in hope of not having to do any additional work)

maksim@treetop:~/kde4/src/kdelibs/khtml$ svn diff ecma/kjs_html.cpp
Index: ecma/kjs_html.cpp
===================================================================
--- ecma/kjs_html.cpp   (revision 865420)
+++ ecma/kjs_html.cpp   (working copy)
@@ -2106,8 +2106,9 @@
           if ( view && view->part() )  {
             if (!view->part()->url().host().isEmpty())
               caption = view->part()->url().host() + " - ";
-            // search all (possibly nested) framesets
-            KHTMLPart *currentPart = view->part()->parentPart();
+            // search all (possibly nested) framesets. We have to start from here
+            // since the frame can be an iframe of ours, too.
+            KHTMLPart *currentPart = view->part();
             while( currentPart != 0L ) {
               if( currentPart->frameExists( form.target().string() ) )
                 block = false;
Comment 6 Maksim Orlovich 2008-10-25 20:11:27 UTC
SVN commit 875819 by orlovich:

Fix how  we find existing frames for the purpose of form target= submission.
This fixes file upload for drupal 6/jquery.form --- its submit  was incorrectly
blocked as a popup attempt

As we refactored this method, also use it for window.open, fixing us blocking 
opens to _self along the way.

While testing this, I noticed that we can crash konq if we do window.open 
and one of the frames doesn't yet have a part yet. Added a workaround 
suggested by dfaure for now, as the proper fix is too risky and should be 
done on unstable branch only.

BUG:172073
BUG:102044


 M  +15 -22    ecma/kjs_html.cpp  
 M  +21 -2     ecma/kjs_window.cpp  
 M  +2 -0      ecma/kjs_window.h  
 M  +3 -2      khtml_part.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=875819
Comment 7 Jakob Petsovits 2008-10-27 19:28:08 UTC
Thanks a lot! That was like my favorite KHTML bug (apart from the more recent derstandard.at crash), I just love to see it working.

Also, now that both of my reported Drupal problems are fixed, I've taken down the test site again as it's an easy target for crackers, running an unreleased development version and stuff. If you need a Drupal test site again, you know where to ask :)