malsup/form — Issue #169: Garbage response using fileUploadIframe
Author: silvafj
Created: 2012-02-16 16:06:35+00:00
State: open

Hi,

The following JSON response works great with Firefox, because it does not get parsed by fileUploadIframe(). When running the same code, through IE9, fileUploadIframe() is called and creates a bad response.

Original response:
{ "status": true, "data": "

\n
Workorders: <\/th>	Order<\/th> <\/tr><\/thead>\n
\n
<\/td>

\n \n<\/div>\n<\/td>

\n
-2<\/option>
-1<\/option>
0<\/option>
1<\/option>
2<\/option><\/select>\n<\/div>\n<\/td> <\/tr>\n
<\/td>

\n \n<\/div>\n<\/td>

\n
-2<\/option>
-1<\/option>
0<\/option>
1<\/option>
2<\/option><\/select>\n<\/div>\n<\/td> <\/tr>\n
<\/td>

\n \n<\/div>\n<\/div><\/td>

\n
-2<\/option>
-1<\/option>
0<\/option>
1<\/option>
2<\/option><\/select>\n<\/div>\n<\/td> <\/tr>\n<\/tbody>\n<\/table>\n

\n<\/div>x<\\\/kbd><\\\/a> to close\", \"download_link_text\": \"Download Original\", \"enable_login\": false, \"enable_contact\": false, \"keys_close\": \"c x 27\", \"keys_previous\": \"p 37\", \"keys_next\": \"n 39\", \"keys_zoom\": \"z\", \"keys_play_pause\": \"32\", \"display_image_size\": \"\", \"image_node_sizes\": \"(\\\\.preview)\", \"trigger_lightbox_classes\": \"img.preview, img.image-preview\", \"trigger_lightbox_group_classes\": \"\", \"trigger_slideshow_classes\": \"\", \"trigger_lightframe_classes\": \"\", \"trigger_lightframe_group_classes\": \"\", \"custom_class_handler\": \"lightbox_ungrouped\", \"custom_trigger_classes\": \"img.image-_original\", \"disable_for_gallery_lists\": 1, \"disable_for_acidfree_gallery_lists\": true, \"enable_acidfree_videos\": true, \"slideshow_interval\": 5000, \"slideshow_automatic_start\": true, \"slideshow_automatic_exit\": true, \"show_play_pause\": true, \"pause_on_next_click\": false, \"pause_on_previous_click\": true, \"loop_slides\": false, \"iframe_width\": 600, \"iframe_height\": 400, \"iframe_border\": 1, \"enable_video\": false }, \"omb\": { \"modulepath\": \"sites\\\/all\\\/modules\\\/custom\\\/omb\" }, \"popups\": { \"originalPath\": \"content\\\/js_add_more\\\/oncallrpt\\\/field_workorders\", \"defaultTargetSelector\": \"div.left-corner > div.clear-block:last\", \"modulePath\": \"sites\\\/all\\\/modules\\\/contrib\\\/popups\", \"autoCloseFinalMessage\": 1 }, \"challenges_module\": { \"modulepath\": \"sites\\\/all\\\/modules\\\/custom\\\/challenges\" }, \"ahah\": { \"edit-book-bid\": { \"url\": \"\\\/book\\\/js\\\/form\", \"event\": \"change\", \"keypress\": null, \"wrapper\": \"edit-book-plid-wrapper\", \"selector\": \"#edit-book-bid\", \"effect\": \"slide\", \"method\": \"replace\", \"progress\": { \"type\": \"throbber\" }, \"button\": false }, \"edit-attach\": { \"url\": \"\\\/upload\\\/js\", \"event\": \"mousedown\", \"keypress\": true, \"wrapper\": \"attach-wrapper\", \"selector\": \"#edit-attach\", \"effect\": \"none\", \"method\": \"replace\", \"progress\": { \"type\": \"bar\", \"message\": \"Please wait...\" }, \"button\": { \"attach\": \"Attach\" } }, \"edit-field-workorders-field-workorders-add-more\": { \"url\": \"\\\/content\\\/js_add_more\\\/oncallrpt\\\/field_workorders\", \"event\": \"mousedown\", \"keypress\": true, \"wrapper\": \"field-workorders-items\", \"selector\": \"#edit-field-workorders-field-workorders-add-more\", \"effect\": \"fade\", \"method\": \"replace\", \"progress\": { \"type\": \"throbber\" }, \"button\": { \"field_workorders_add_more\": \"Add another item\" } }, \"edit-field-challenges-field-challenges-add-more\": { \"url\": \"\\\/content\\\/js_add_more\\\/oncallrpt\\\/field_challenges\", \"event\": \"mousedown\", \"keypress\": true, \"wrapper\": \"field-challenges-items\", \"selector\": \"#edit-field-challenges-field-challenges-add-more\", \"effect\": \"fade\", \"method\": \"replace\", \"progress\": { \"type\": \"throbber\" }, \"button\": { \"field_challenges_add_more\": \"Add another item\" } } }, \"wysiwyg\": { \"configs\": { \"tinymce\": { \"global\": { \"editorBasePath\": \"\\\/sites\\\/all\\\/libraries\\\/tinymce\\\/jscripts\\\/tiny_mce\", \"execMode\": \"\" }, \"format1\": { \"button_tile_map\": true, \"document_base_url\": \"\\\/\", \"mode\": \"none\", \"plugins\": \"advimage,advlink,fullscreen,paste,table\", \"theme\": \"advanced\", \"width\": \"100%\", \"strict_loading_mode\": true, \"convert_urls\": false, \"entities\": \"160,nbsp,173,shy,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm\", \"apply_source_formatting\": 0, \"convert_fonts_to_spans\": 1, \"language\": \"en\", \"paste_auto_cleanup_on_paste\": 1, \"preformatted\": 0, \"remove_linebreaks\": 0, \"verify_html\": false, \"content_css\": \"\\\/sites\\\/default\\\/themes\\\/vodafone\\\/style-texts.css\", \"extended_valid_elements\": \"img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name],a[name|href|target|title|class|onfocus|onblur|onclick|ondlbclick|onmousedown|onmouseup|onmouseover|onmouseout|onkeypress|onkeydown|onkeyup|id|style|rel],font[face|size|color|style],span[class|align|style]\", \"file_browser_callback\": \"imceImageBrowser\", \"inline_styles\": true, \"theme_advanced_resize_horizontal\": false, \"theme_advanced_resizing_use_cookie\": false, \"theme_advanced_path_location\": \"bottom\", \"theme_advanced_resizing\": 1, \"theme_advanced_toolbar_location\": \"top\", \"theme_advanced_toolbar_align\": \"left\", \"theme_advanced_blockformats\": \"p,address,pre,h1,h2,h3,h4,h5,h6\", \"theme_advanced_buttons1\": \"bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,undo,redo,link,unlink,image,code,removeformat,fontsizeselect,styleselect,fullscreen,pastetext,pasteword,tablecontrols\", \"theme_advanced_buttons2\": \"\", \"theme_advanced_buttons3\": \"\" }, \"format3\": { \"button_tile_map\": true, \"document_base_url\": \"\\\/\", \"mode\": \"none\", \"plugins\": \"advimage,advlink,fullscreen,paste,preview,table\", \"theme\": \"advanced\", \"width\": \"100%\", \"strict_loading_mode\": true, \"convert_urls\": false, \"entities\": \"160,nbsp,173,shy,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm\", \"apply_source_formatting\": 0, \"convert_fonts_to_spans\": 1, \"language\": \"en\", \"paste_auto_cleanup_on_paste\": 1, \"preformatted\": 1, \"remove_linebreaks\": 0, \"verify_html\": false, \"content_css\": \"\\\/sites\\\/default\\\/themes\\\/vodafone\\\/style-texts.css\", \"extended_valid_elements\": \"img[src|alt|title|align|width|height|usemap|hspace|vspace|border|style|class|onmouseover|onmouseout|id|name],a[name|href|target|title|class|onfocus|onblur|onclick|ondlbclick|onmousedown|onmouseup|onmouseover|onmouseout|onkeypress|onkeydown|onkeyup|id|style|rel],font[face|size|color|style],span[class|align|style]\", \"file_browser_callback\": \"imceImageBrowser\", \"inline_styles\": true, \"theme_advanced_resize_horizontal\": false, \"theme_advanced_resizing_use_cookie\": false, \"theme_advanced_path_location\": \"bottom\", \"theme_advanced_resizing\": 1, \"theme_advanced_toolbar_location\": \"top\", \"theme_advanced_toolbar_align\": \"left\", \"theme_advanced_blockformats\": \"p,address,pre,h1,h2,h3,h4,h5,h6\", \"theme_advanced_buttons1\": \"bold,italic,underline,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,outdent,indent,undo,redo,link,unlink,image,code,removeformat,styleselect,fullscreen,pasteword,preview,tablecontrols\", \"theme_advanced_buttons2\": \"\", \"theme_advanced_buttons3\": \"\" } } }, \"plugins\": [ ], \"disable\": \"Disable rich-text\", \"enable\": \"Enable rich-text\" }, \"imce\": { \"url\": \"\\\/imce?app=tinymce%7Curl%40\" }, \"nodeRelationships\": { \"fieldSettings\": { \"field_challenges\": { \"maxAllowedValues\": 0, \"ahahSearchUrl\": \"\\\/noderelationships\\\/ahah\\\/search\\\/oncallrpt\\\/field_challenges\", \"searchUrl\": \"\\\/noderelationships\\\/search\\\/oncallrpt\\\/field_challenges\", \"viewInNewWindow\": false }, \"field_workorders\": { \"maxAllowedValues\": 0, \"ahahSearchUrl\": \"\\\/noderelationships\\\/ahah\\\/search\\\/oncallrpt\\\/field_workorders\", \"searchUrl\": \"\\\/noderelationships\\\/search\\\/oncallrpt\\\/field_workorders\", \"viewInNewWindow\": false } }, \"viewUrl\": \"\\\/node\\\/nid\", \"editUrl\": \"\\\/node\\\/nid\\\/edit\" } });<\/script>" }

Response after being parsed:
{ "status": true, "data": "\n Workorders: <\/th>Order<\/th> <\/tr><\/thead>\n\n <\/td>\n \n<\/div>\n<\/td>\n -2<\/option>-1<\/option>0<\/option>1<\/option>2<\/option><\/select>\n<\/div>\n<\/td> <\/tr>\n <\/td>\n \n<\/div>\n<\/td>\n -2<\/option>-1<\/option>0<\/option>1<\/option>2<\/option><\/select>\n<\/div>\n<\/td> <\/tr>\n <\/td>\n \n<\/div>\n<\/div><\/td>\n -2<\/option>-1<\/option>0<\/option>1<\/option>2<\/option><\/select>\n<\/div>\n<\/td> <\/tr>\n<\/tbody>\n<\/table>\n\n<\/div>jQuery.extend(Drupal.settings, { \"basePath\": \"\\\/\", \"lightbox2\": { \"rtl\": 0, \"file_path\": \"\\\/(\\\\w\\\\w\\\/)sites\\\/default\\\/files\", \"default_image\": \"\\\/sites\\\/all\\\/modules\\\/contrib\\\/lightbox2\\\/images\\\/brokenimage.jpg\", \"border_size\": 10, \"font_color\": \"000\", \"box_color\": \"fff\", \"top_position\": \"\", \"overlay_opacity\": \"0.8\", \"overlay_color\": \"000\", \"disable_close_click\": true, \"resize_sequence\": 0, \"resize_speed\": 400, \"fade_in_speed\": 400, \"slide_down_speed\": 600, \"use_alt_layout\": false, \"disable_resize\": false, \"disable_zoom\": false, \"force_show_nav\": false, \"show_caption\": true, \"loop_items\": false, \"node_link_text\": \"View Image Details\", \"node_link_target\": false, \"image_count\": \"Image !current of !total\", \"video_count\": \"Video !current of !total\", \"page_count\": \"Page !current of !total\", \"lite_press_x_close\": \"press x<\\\/kbd><\\\/a> to close\", \"download_link_text\": \"Download Original\", \"enable_login\": false, \"enable_contact\": false, \"keys_close\": \"c x 27\", \"keys_previous\": \"p 37\", \"keys_next\": \"n 39\", \"keys_zoom\": \"z\", \"keys_play_pause\": \"32\", \"display_image_size\": \"\", \"image_node_sizes\": \"(\\\\.preview)\", \"trigger_lightbox_classes\": \"img.preview, img.image-preview\", \"trigger_lightbox_group_classes\": \"\", \"trigger_slideshow_classes\": \"\", \"trigger_lightframe_classes\…

The offending code is this:
xhr.responseText = b.textContent ? b.textContent : b.innerText;

But I'm not being able to understand what the problem is.

Thanks,
Fernando