Download-Handling of XML Files

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Download-Handling of XML Files

Postby dbuechel » Wed Mar 03, 2021 4:01 pm

We are using CefSharp, and have implemented IDownloadHandler.OnBeforeDownload(...) to handle the download of an XML file with a custom file extension. After updating to the current version, the handler apparently no longer gets triggered and the browser instead renders the XML file content. How can we revert to the old behavior, and if there are any further changes like this in Chromium / CEF, where can we find information about these? We found the bug in production and would like to avoid such situations in the future.
dbuechel
Newbie
 
Posts: 9
Joined: Wed Mar 03, 2021 3:55 pm

Re: Download-Handling of XML Files

Postby amaitland » Thu Mar 04, 2021 7:19 pm

For clarity please provide the exact version you are having problems with and the version that was previously working.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Download-Handling of XML Files

Postby dbuechel » Sun Mar 07, 2021 10:07 pm

I think this happened when moving from version 85.3.13 to version 86.0.2. The latest version 87.1.1 still has the same issue.
dbuechel
Newbie
 
Posts: 9
Joined: Wed Mar 03, 2021 3:55 pm

Re: Download-Handling of XML Files

Postby amaitland » Mon Mar 08, 2021 5:56 pm

What are the steps to reproduce this exactly?

You can view the chromium issue tracker bugs assigned to a particular milestone the following being for M86

https://bugs.chromium.org/p/chromium/is ... M-86&can=1

You can review the CEF commits on the bitbucket project site.

Adding integration tests to verify the expected behaviour is something to consider.

Others might have additional insight into tracking chromium changes.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Download-Handling of XML Files

Postby dbuechel » Sat Mar 13, 2021 10:38 pm

Thanks for your reply. Below the steps to visualize the issue:

1. Download the CEF sample application
2. Navigate to https://safeexambrowser.org/testing/Dem ... leNoPW.seb
3. The XML file content is rendered

Though the real issue seems to be that the download handler isn't called, instead the XML file content is rendered. We use CefSharp's IDownloadHandler.OnBeforeDownload() (see https://github.com/SafeExamBrowser/seb-win-refactoring/blob/master/SafeExamBrowser.Browser/Handlers/DownloadHandler.cs#L47), and this somehow stopped working after updating the browser engine.
dbuechel
Newbie
 
Posts: 9
Joined: Wed Mar 03, 2021 3:55 pm

Re: Download-Handling of XML Files

Postby amaitland » Sun Mar 21, 2021 11:40 pm

Loading https://safeexambrowser.org/testing/Dem ... leNoPW.seb in Chrome shows the file as formatted xml.

The content-type is text/xml so you'll get whatever the default behaviour for Chromium when opening a file of that content-type (mime-type).

Either change the content-type or add a Content-Disposition header.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Download-Handling of XML Files

Postby dbuechel » Tue Mar 23, 2021 3:30 pm

Thanks a lot for your help with this issue. I am a bit lost though, according to our web content manager, nothing has changed on their side. Could it thus be that Chromium has started to render files when they have the content disposition "text/xml", ignoring the file extension? Because as already mentioned, this used to work, we didn't change anything related to this aspect in the code, so something somewhere else must have changed...
dbuechel
Newbie
 
Posts: 9
Joined: Wed Mar 03, 2021 3:55 pm

Re: Download-Handling of XML Files

Postby amaitland » Sat Mar 27, 2021 12:36 am

It's quite possible that Chromium was only rendering xml files based on their file extension rather than their content type. It's also possible this is CEF specific, some change that was made when upgrading to a newer Chromium version.

Generally speaking Content Type should be used to determine how the file should be handled. File extension is usually mapped to content type, it's pretty rate that it's used directly.

If Chromium only displayed xml files based on their extension then that was likely considered a bug.

You'd have to download an old version of Chromium to see what the exact behaviour was.

If you need a programmatic fix you can probably check the file extension in OnBeforeBrowser, cancel the navigation and call StartDownload to force a download
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am

Re: Download-Handling of XML Files

Postby dbuechel » Tue Mar 30, 2021 11:53 am

Thanks a lot for your help. I will try to implement the workaround as you suggested. Though it would be great if CEF would provide the possibility to control whether and which file types should be automatically rendered by the engine.
dbuechel
Newbie
 
Posts: 9
Joined: Wed Mar 03, 2021 3:55 pm

Re: Download-Handling of XML Files

Postby amaitland » Tue Mar 30, 2021 2:57 pm

If https://bitbucket.org/chromiumembedded/ ... esponse-in is implemented then modifying the content type header should be possible.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 46 guests