Problem/Motivation

Internet Explorer is supposed to be a HTTP-based HTML browser. There are a lot of examples where neither HTTP nor HTML is implemented properly.
One example is the concept of Content-Type headers. If you specify application/json as such header, then IE 9
starts to download the response. This Content-Type is set by AjaxResponse by default, so file uploads for example don't work in IE.

Random observation:
Default accept header

image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/msword, */*	

Steps to reproduce:

  • Using Internet Explorer 11 on Windows 7
  1. Install Drupal 8.0.x using the Standard profile
  2. Open Internet Explorer 11
  3. Browse to node/add/article
  4. Press F12 to open the IE Developer Tools
  5. Find the Document Mode pull-down menu at the upper-righthand corner of the Developer tools, and select '9'
  6. In the 'Add Article' Image field, click Browse to add an image
  7. select a sample image file from the Upload dialog and click open
  • Behavior in IE9 emulation is a continuously spinning-blue process wheel next to the Upload botton, and no preview image appears.
  • Behavior in IE10, IE11, and Chrome is preview image that appears below the Image and fields.

Proposed resolution

Figure out the best solution.

Remaining tasks

User interface changes

API changes

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug, because it breaks uploading files for IE 9 users.
Issue priority Major, because it is not broken for every user but just a small subset of old IE users.
Disruption Just internal changes. This makes the behaviour more similar to how Drupal 7 worked.

Comments

wim leers’s picture

Internet explorer is supposed to be a HTTP based HTML browser. There are a lot of examples where neither HTTP nor HTML is implemented properly.

ROFL :D

dawehner’s picture

StatusFileSize
new464 bytes

Let's try this "solution"

dawehner’s picture

Let's try this "solution"

dawehner’s picture

Let's try this "solution"

dawehner’s picture

Let's try this "solution"

dawehner’s picture

Let's try this "solution"

Crell’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 23394912-2.patch, failed testing.

webflo’s picture

Status: Needs work » Needs review
StatusFileSize
new3.3 KB
webflo’s picture

+++ b/core/lib/Drupal/Core/Controller/AjaxController.php
@@ -11,6 +11,7 @@
+use Symfony\Component\HttpFoundation\Response;

Sorry added this line accidentally.

dawehner’s picture

I wonder whether we can come up with some basic integration test, to ensure that we get the proper header?

+++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
@@ -78,6 +78,20 @@ public function prepareResponse(Request $request) {
+    // Add proper HTTP Header for IE.
+    $accept = $request->headers->get('accept');
+    if (strpos($accept, 'text/html') !== FALSE) {
+      $this->headers->set('Content-Type', 'text/html; charset=utf-8');

Sad story ...
It would be great to add an TODO to improve this strpos once #2331919: Implement StackNegotiation is in.

webflo’s picture

AjaxResponse has to handle two diffrent request headers.

  1. Standard XHR Requests: application/json
  2. AJAX Requests from jQuery Form (Form API AJAX): text/html

jQuery Form falls back to submit via a hidden iFrame in Browser which does not support File Uploads via XHR Requests. More documentation about this is on http://malsup.com/jquery/form/#file-upload.
Maybe we should explicit check for HTTP_X_REQUESTED_WITH as described in this example?

webflo’s picture

Priority: Major » Critical

Bump to critical because IE 9 is a fully supported browser.

seanAtUSDA’s picture

In my custom applications, I have run into the same issue with IE. I resorted to using a content-type of text/plain for all of my JSON responses.

dawehner’s picture

@seanAtUSDA
Would you mind manually testing this manually in various IE variants? This would be really great!

wim leers’s picture

+++ b/core/lib/Drupal/Core/EventSubscriber/ContentControllerSubscriber.php
@@ -44,6 +44,7 @@ public function __construct(ContentNegotiation $negotiation) {
+    'iframeupload' => 'controller.ajax:content',

+++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
@@ -129,20 +129,6 @@ public function onJson(GetResponseForControllerResultEvent $event) {
-  public function onIframeUpload(GetResponseForControllerResultEvent $event) {
-    $response = $event->getResponse();
-
-    // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification
-    // and Skype's Browser Highlighter, convert URLs, phone numbers, etc. into
-    // links. This corrupts the JSON response. Protect the integrity of the
-    // JSON data by making it the value of a textarea.
-    // @see http://malsup.com/jquery/form/#file-upload
-    // @see http://drupal.org/node/1009382
-    $html = '<textarea>' . $response->getContent() . '</textarea>';
-
-    return new Response($html);
-  }

YAY! CONSISTENCY!

wim leers’s picture

Issue summary: View changes
Issue tags: +Needs more sarcasm

Already added some, but could use more :)

dawehner’s picture

Issue tags: +Needs manual testing

.

dawehner’s picture

Issue summary: View changes
Issue tags: -
catch’s picture

According to http://www.netmarketshare.com/browser-market-share.aspx?qprid=2&qpcustomd=0 IE9 usage is down to 9%. I'd personally be OK with treating IE9 bugs as 'major' - we'd still fix issues if they come up as opposed to won't fix, but not hold up release on it.

For administering Drupal sites, you should be able to use the latest version of a major browser. If you're not allowed to use the latest version of a supported browser to do that, you're probably not going to be allowed to use Drupal 8 anyway.

For site visitors it's up to the site builder to decide which browsers they support and which features are exposed to end users. Some sites work fine without users triggering ajax responses, some won't.

Crell’s picture

If this bug is in IE9, does it mean it's also in IE 8? I know we have already told IE 8 to get stuffed, but it has a disturbingly large presence on that pie chart...

I don't recall the last time I used IE period, much less an old version of it, so I wouldn't mind downgrading to major here.

dawehner’s picture

According to various stackoverflow entries, this seems indeed to be the case as well for IE 8.

catch’s picture

IE8 doesn't get any JavaScript at all, so there's no AJAX request to fail.

dawehner’s picture

Even I don't care about the IE9 users so much, I do care about the site builders
which would have to fix that for some of their users. Figuring out what is going on here,
is extremly frustrating, its far from being obvious.

Given that I would argue we should make a general policy how much we would support IE9, make some decision there,
but get this issue in, given that we save time for us, the community.

Does anyone has an oppinion?

catch’s picture

xjm’s picture

xjm’s picture

Discussed with @catch, @alexpott, @webchick, @Dries, and @effulgentsia. For now, IE9 is a supported browser, and this is actually a significant bug that site builders and users can't reasonably work around if they can't simply use a different browser (which is common for IE users). If we decide in #2390621: [policy, no patch] Update Drupal's browser support policy to change our IE9 support we will downgrade this.

ericjenkins’s picture

I am at a Sprint right now. I am following: https://www.drupal.org/contributor-tasks/add-steps-to-reproduce

I have added "Needs steps to reproduce" tag to this issue. I will remove this tag if I can reproduce the steps and document it.

ericjenkins’s picture

Issue summary: View changes
Issue tags: -Needs steps to reproduce

Successfully reproduced the image upload quirk using IE9 emulation in IE11. Added a Steps to reproduce section to the Issue Summary and documented the steps to reproduce there. Removed the tag: Needs steps to reproduce.

dawehner’s picture

+++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
@@ -78,6 +78,20 @@ public function prepareResponse(Request $request) {
+      // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification
+      // and Skype's Browser Highlighter, convert URLs, phone numbers, etc. into
+      // links. This corrupts the JSON response. Protect the integrity of the
+      // JSON data by making it the value of a textarea.
+      // @see http://malsup.com/jquery/form/#file-upload
+      // @see http://drupal.org/node/1009382
+      $this->setContent('<textarea>' . $this->data  . '</textarea>');

Do we maybe want to check first whether the request format is iframeupload?

corbacho’s picture

StatusFileSize
new5.51 KB
new263.94 KB
new333.66 KB

I've spent some time researching about this bug and testing
This is how the problem looks in Windows 7 - IE9 not emulated:

As webflo said, this bug is present only in forms with file uploads, in old browsers that don't support XHR file uploading. In that case, the jQuery Form plugin switches to the iframe mechanism.

Also, we have already implemented in Drupal's ajax.js file a flag ajax_iframe_upload that can be read from the PHP side.

This bug is not present in Drupal 7 because ajax_deliver takes care of setting the correct header. When Drupal 7 ajax system was removed #1677304: Remove drupal_deliver_page(), ajax_deliver(), drupal_deliver_html_page() I think this was overlooked.

So, we need to recover this important piece of code from Drupal 7's ajax_deliver.

 // Browser IFRAMEs expect HTML. With most other content types, Internet
      // Explorer presents the user with a download prompt.
      drupal_add_http_header('Content-Type', 'text/html; charset=utf-8');

This fix is not only for IE9.
From jQuery file upload wiki FAQ:

XMLHttpRequest File Uploads
The following browsers support XHR file uploads, which allows advanced usage of the file upload API:
Desktop browsers

Google Chrome
Apple Safari 5.0+
Mozilla Firefox 4.0+
Opera 12.0+
Microsoft Internet Explorer 10.0+
Mobile browsers

Apple Safari Mobile on iOS 6.0+
Google Chrome on iOS 6.0+
Google Chrome on Android 4.0+
Default Browser on Android 3.2+
Opera Mobile 12.0+

I'm not 100% sure if all these browsers need the content-type "text/html", but this is how Drupal 7 was behaving, and there wasn't problems. Also the jQuery Form FAQ suggests that IE is not the only browser.

The patch attached is a reroll of webflo's patch with a couple of changes.
.
Screenshot of IE9 response header and content, after the patch:

Please, review in the patch if it's good to add iframeupload in the file core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php

dawehner’s picture

@corbacho
Is this still the exact same patch? In case I would still ask what I asked in #30

corbacho’s picture

@dawehner Patch at #31 is addressing your concern

+    if ($request->get('ajax_iframe_upload', FALSE)) {

it's the same condition than in ajax_deliver of Drupal 7

dawehner’s picture

+++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
@@ -78,6 +78,19 @@ public function prepareResponse(Request $request) {
+    // Add proper HTTP Header for IE.
+    if ($request->get('ajax_iframe_upload', FALSE)) {
+      $this->headers->set('Content-Type', 'text/html; charset=utf-8');
+
+      // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification

Afaik the problem is not only for ajax uploads but also for every kind of ajax call, so the if should be around the textarea part of the code?

corbacho’s picture

The if is already wrapping the "textarea" part of the code.
Do you mean that setting "Content-Type" to "text/html" is needed for every ajax upload? and should be outside of the if ?
Mhh, I don't think so.
ajax_deliver was behaving like the patch I submitted. And the jquery form plugin also says Iframe based uploads require a Content-type of text/plain or text/html for the JSON response in the FAQ (link in #30, where I explain with more details the logic of the patch)

dawehner’s picture

Ah good point, so this is really just related with uploading files.

This issue needs some kind of beta evaluation but beside from this its done.

dawehner’s picture

+++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
@@ -91,20 +91,6 @@ public function onJson(GetResponseForControllerResultEvent $event) {
diff --git a/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php b/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php

diff --git a/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php b/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php
index 50f3bc1..58b3034 100644

index 50f3bc1..58b3034 100644
--- a/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php

--- a/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php
+++ b/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php

+++ b/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php
+++ b/core/modules/taxonomy/src/Plugin/entity_reference/selection/TermSelection.php
@@ -60,7 +60,8 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA

@@ -60,7 +60,8 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTA
     $options = array();
 
     $bundles = entity_get_bundles('taxonomy_term');
-    $bundle_names = !empty($this->instance['settings']['handler_settings']['target_bundles']) ? $this->instance['settings']['handler_settings']['target_bundles'] : array_keys($bundles);
+    $handler_settings = $this->fieldDefinition->getSetting('handler_settings');
+    $bundle_names = !empty($handler_settings['target_bundles']) ? $handler_settings['target_bundles'] : array_keys($bundles);
 
     foreach ($bundle_names as $bundle) {

Is this change related to the issue? Beside for that the issue looks RTBC.

corbacho’s picture

StatusFileSize
new619 bytes
new4.47 KB

that code shouldn't be there, indeed. Thanks for catching that Daniel

corbacho’s picture

StatusFileSize
new787 bytes

correct interdiff. (See "reverted" in the top of the interdiff)

dawehner’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

Added a beta evaluation.

wim leers’s picture

+++ b/core/lib/Drupal/Core/Ajax/AjaxSubscriber.php
@@ -27,6 +27,7 @@ public function onKernelRequest(GetResponseEvent $event) {
     $request->setFormat('drupal_ajax', 'application/vnd.drupal-ajax');
...
+    $request->setFormat('iframeupload', 'application/vnd.drupal-ajax');

Do we need extra docs regarding how we deal with multiple formats using the same MIME types?

corbacho’s picture

Good point Wim. Or, do you recommend to create a specific mime type for the iframe upload?

With this patch, $request->getFormat('application/vnd.drupal-ajax') seems to always return the same format (just by looking at source code, not tested)

wim leers’s picture

Or, do you recommend to create a specific mime type for the iframe upload?

Unless there's a reason to have it use the same MIME type, I think that'd be better, yes. Bonus from doing that: we can channel our frustration with IE in there. application/vnd.drupal-ie-lte-9-sucks-beyond-compare, for example.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

That sounds like a needs work.

corbacho’s picture

Status: Needs work » Needs review
StatusFileSize
new1.2 KB
new5.14 KB

I find difficult to improve that mime type name

Tested manually in Windows 7 VM - IE9

Status: Needs review » Needs work

The last submitted patch, 45: 2339491-45-iframeupload.patch, failed testing.

effulgentsia’s picture

Title: Ajax fails on IE 9 » Ajax file uploads fail on IE 9
StatusFileSize
new3.6 KB
new4.32 KB

Do we need that format / mime type at all? If we do, we need to set it somewhere in the JS, but I don't think we do. See attached patch, including its docs.

I don't have a Windows environment handly. @corbacho: can you test this please?

effulgentsia’s picture

Status: Needs work » Needs review
corbacho’s picture

@effulgentsia. Yep, it works in IE9
And your comments in the code explains better the bug.

I think this is ready!, but I let someone else to mark it RTBC, to give more time if someone wants to argue this comment:

    // Since this affects the format of the output, it could be argued that
    // this should be implemented as a separate Accept MIME type. However,
    // that would require separate variants for each type of AJAX request
    // (e.g., drupal-ajax, drupal-dialog, drupal-modal), so for expediency,
    // this browser workaround is implemented via a GET or POST parameter.

Thanks!

dawehner’s picture

  1. +++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
    @@ -78,6 +78,32 @@ public function prepareResponse(Request $request) {
    +    if ($request->get('ajax_iframe_upload', FALSE)) {
    

    so is this really $_REQUEST or would it be post all the time? Its an upload, so it should be post?

  2. +++ b/core/lib/Drupal/Core/ContentNegotiation.php
    @@ -30,11 +30,6 @@ class ContentNegotiation {
       public function getContentType(Request $request) {
    -    // AJAX iframe uploads need special handling, because they contain a JSON
    -    // response wrapped in <textarea>.
    -    if ($request->get('ajax_iframe_upload', FALSE)) {
    -      return 'iframeupload';
    -    }
     
    
    +++ b/core/lib/Drupal/Core/EventSubscriber/ViewSubscriber.php
    @@ -91,20 +91,6 @@ public function onJson(GetResponseForControllerResultEvent $event) {
    -  public function onIframeUpload(GetResponseForControllerResultEvent $event) {
    -    $response = $event->getResponse();
    -
    -    // Browser IFRAMEs expect HTML. Browser extensions, such as Linkification
    -    // and Skype's Browser Highlighter, convert URLs, phone numbers, etc. into
    -    // links. This corrupts the JSON response. Protect the integrity of the
    -    // JSON data by making it the value of a textarea.
    -    // @see http://malsup.com/jquery/form/#file-upload
    -    // @see http://drupal.org/node/1009382
    -    $html = '<textarea>' . $response->getContent() . '</textarea>';
    -
    -    return new Response($html);
    -  }
    

    Are we sure we don't accidentally introduce a regression? Is onIframeUpload still called somewhere somehow? What happens if you don't use AjaxResponse but write your own custom implementation for an upload?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

The more I think about it, the more I think its a reasonable assumption.

effulgentsia’s picture

Assigned: Unassigned » effulgentsia
Status: Reviewed & tested by the community » Needs work

Actually, I think #50 brings up good points. I have an idea for one other option for us to consider. Will try to post it today.

Crell’s picture

I await effulgentsia's alternative, but #47 looks fairly good to me.

webflo’s picture

Please note, the last patch does not work. The file upload part is fine but other ajax operations in the same form are failing. jQuery Form adds the ajax_iframe_upload flag to the file upload request only. It is not present during any other ajax operations (e.g. field widget with multiple values). IE 9 fails to send the proper accept header if a file upload field is present in the form.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs manual testing

Right, so the approach to check for an ajax upload is wrong. Given that I think we can RTBC patch #9 which is used in the wild since a LONG time.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

so re-rtbcing an old patch without re-uploading is a bit of a mare from an automated re-test of the rtbc queue point of view. Based #10 pinted out a minor nit with #9 and in #52 @effulgentsia says he has some ideas...

effulgentsia’s picture

@webflo: can you add a comment here with the exact Accept header and POST data that IE 9 sends during a non-file-upload AJAX operation on a form that has a file upload field?

effulgentsia’s picture

Additionally, it would also be helpful to know the Accept header it sends during an AJAX operation on a form without any file upload fields.

corbacho’s picture

StatusFileSize
new461.29 KB
new128.69 KB
new171.4 KB
new313.84 KB

I couldn't replicate the bug of @webflo

Patch works. I tried on Article content type, changing the image field to "unlimited", and also testing the autocomplete ajax.

Testing on a Virtual Machine, Windows 7, IE9

@effulgentsia, information you requested:
Default Article content type, uploading an image:
ie9-upload-POST-request.png

Default Article content type, autocomplete request (GET request have empty Request Body, obviously)
ie9-AJAX-GET-request.png

Modified Basic page content type by adding a Unlimited Text Field, clicking "Add another item" (AJAX POST request without file field in the form)
ie9-not-upload-POST-request.png
Full request body: http://pastebin.com/1U1xuF8Z

dawehner’s picture

Patch works. I tried on Article content type, changing the image field to "unlimited", and also testing the autocomplete ajax.

The problem is something else than you tested. Its about non upload ajax requests in forms which have a file upload element as well.

corbacho’s picture

I see. It fails, the AJAX response is an HTML document :(

I added a unlimited Text field to Article content type.
Then, clicking "Add another item" makes this request/response:

ie9-non-upload-post-AJAX-with-fileupload-in-the-form.jpg

dawehner’s picture

Title: Ajax file uploads fail on IE 9 » Ajax requests on forms with files fail on IE 9

Adapt the issue title to explain directly what is going on wrong.

corbacho’s picture

StatusFileSize
new6.84 KB

As you saw in the screenshots, the POSTs requests in IE9 has accept header "text/html" always that the form has a File Upload field

We lose our ability to identify what type of Ajax call is (drupal_modal, drupal_ajax, drupal_dialog), because all our ContentNegotiation and renderer is based on mime types.

I made a work-around (1 line in ajax.js), so we can expose the original mime type during the ContentNegotiation phase.
options.extraData.ajax_iframe_upload_mime_type = options.accepts.json + '-iframeupload';

I wish someone would have a genius idea to simplify a bit more the patch.

But this currently, works in IE9 and Chrome, and there is not much code duplication, only duplicated mime types.
I've to do more extensive testing, but first, do you agree with the approach?

corbacho’s picture

Status: Needs work » Needs review

needs review

dawehner’s picture

@corbacho
To be honest, I don't get why we can't go back to the approach of webflo. Does your patch really fixes the case of having any ajax request in a form with an upload form?

Status: Needs review » Needs work

The last submitted patch, 63: 2339491-63-ie9-iframeupload.patch, failed testing.

corbacho’s picture

@dawehner I wish too! But weblo's approach worked in *that* time, when the content negotiation and ajax rendering system was different. I tried now similar approach but does not work.

Yes, #63 patch works for all ajax requests types we have been discussing in the issue.

corbacho’s picture

The bright side: this "fix" will be removed as soon as we drop IE9 support :)

corbacho’s picture

Status: Needs work » Needs review
StatusFileSize
new8 KB
new1.06 KB

Same patch than #63, with fix on test ReadTest.php

larowlan’s picture

Issue summary: View changes
StatusFileSize
new149.91 KB
new333.84 KB
new114.36 KB
+++ b/core/lib/Drupal/Core/EventSubscriber/DefaultExceptionSubscriber.php
@@ -209,7 +209,7 @@ protected function getFormat(Request $request) {
+    if (in_array($format, ['drupal_modal', 'drupal_dialog', 'drupal_ajax', 'drupal_modal_iframe', 'drupal_dialog_iframe', 'drupal_ajax_iframe', ])) {

nitpick: We don't normally add the extra ',' when the array is on one line - but - an array of over 80 chars should be split according to coding standards.

Real pity about the hardcoding/duplication here but I guess we didn't get #2331919: Implement StackNegotiation so not much we can do.

Manual tests:

Now I'm going to wash in kerosene to remove the traces of IE.

dawehner’s picture

StatusFileSize
new517.05 KB
new3.68 KB

@corbacho
Its great that you have the motivation to work on this issue, but please be always aware what the actual two problems are we have to solve. Its not just the image upload.

Give it a quick test and it doesn't work yet as expected.

Test instructions:

  • Add a multivalue text field to the article content type
  • Click "add another item" on the article creation form # This fails
  • Upload an image, this works.

Instead here is a version of webflo's patch in https://www.drupal.org/node/2339491 which works, see screenshot.
It required an additional fix in MainContentRenderersPass which might the be reason @corbacho could not really follow previous

Status: Needs review » Needs work

The last submitted patch, 71: 2339491-71.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new4.62 KB
new969 bytes

Let's adapt the test to be a little bit less strict, to not couple to the exact error message.

corbacho’s picture

@dawehner I know that! :)
My patch worked in that scenario too, those were the steps I followed. Did you flush the aggregated JavaScript ? I wonder why didn't work for you.

.. but anyhow... I'm not wasting more time there.. (I'm not that motivated to keep killing hours in IE9).

I like more your patch, that was a smart fix to overload the "drupal_ajax" renderer, and makes everything much simpler :)

Before, every format had a renderer and mimetype associated in a 1:1:1 mapping. Not now, that's why the test failed in #71 returning "null". But I trust that this wouldn't have any further consequences.

The patch offers a fix for the "drupal_ajax" format. My only concern is what happens with drupal_dialog and drupal_modal formats. They have different renderers and arguments, do they keep working as normally when renderer is different ?

Otherwise, thumbs up!

Nitpick: I liked effulgentsia code comment at #47 explaining the bug, we could use it instead of the old one

larowlan’s picture

Status: Needs review » Reviewed & tested by the community

Much cleaner than #70, addresses my whining about duplication.
Let's do it.

dawehner’s picture

My patch worked in that scenario too, those were the steps I followed. Did you flush the aggregated JavaScript ? I wonder why didn't work for you.

When I tested your patch I recieved a 500 error, this wasn't the JS, pretty sure, hopefully, in case it was, I'm sorry.

I'm not that motivated to keep killing hours in IE9

This is a good idea in general!

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

Let's get the comment from #47 to explain:

+++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php
@@ -115,6 +115,20 @@ public function prepareResponse(Request $request) {
+      $this->headers->set('Content-Type', 'text/html; charset=utf-8');

Also

My only concern is what happens with drupal_dialog and drupal_modal formats. They have different renderers and arguments, do they keep working as normally when renderer is different ?

What's the answer to this?

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new7.24 KB
new3.21 KB

Let's get the comment from #47 to explain:

Sure, expanded one part of the comment to include the usecase we struggled with along the way.

My only concern is what happens with drupal_dialog and drupal_modal formats. They have different renderers and arguments, do they keep working as normally when renderer is different ?

Well, but those are only happen on clicking some links, so there is no form involved which leads to an upload form.

On top of that, added some unit test.

corbacho’s picture

Status: Needs review » Reviewed & tested by the community

Tested in IE9 and Chrome. It works well (image uploads and also unlimited text field 'Add another item' button), well documented and that Unit Test was great great to have :)

Thumbs up!

PS. The content I put in the unlimited text (formatted) field is not saved. But this is not related to this patch, it happens also without the patch. I will open an issue ..

dawehner’s picture

PS. The content I put in the unlimited text (formatted) field is not saved in the node. But this is not related to this patch, it happens also without the patch. I will open an issue if I don't find one open.

Oh wow, is that just in IE?

corbacho’s picture

Assigned: effulgentsia » Unassigned

no, chrome too #2442379: Content of Unlimited Text Field not saved
Anyway, this is unrelated. This shouldn't stop this critical fix to be committed.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This issue addresses a critical bug and is allowed per https://www.drupal.org/core/beta-changes. Committed 9c0bfb2 and pushed to 8.0.x. Thanks!

  • alexpott committed 9c0bfb2 on 8.0.x
    Issue #2339491 by corbacho, dawehner, larowlan, effulgentsia, webflo:...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

stephenrobinson’s picture

I did this:

/**
  * Implementation of hook hook_ajax_render_alter().
  */
function privatedownloadmanager_ajax_render_alter(&$commands) { // stop IE treating ajax response as a file attachment
  if(strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 9.0')>-1 || strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE 8.0')>-1 || strpos($_SERVER["HTTP_USER_AGENT"], 'WOW64')>-1 || strpos($_SERVER["HTTP_USER_AGENT"], 'Trident')>-1){
    if(isset($commands[0]['settings']['urlIsAjaxTrusted'])){
      $url='';
      foreach ($commands[0]['settings']['urlIsAjaxTrusted'] as $url => $value) {
        break;
      }
      if(valid_url($url)){
        if( strpos($url, '/file/ajax')===0 || strpos($url, '/system/ajax')===0){
          drupal_add_http_header('content-type', 'text/html');
        }
      }
    }
  }
}