Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Check Content-Type header before parsing AJAX response as HTML #8649

Merged
merged 1 commit into from
Jun 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions js/widgets/pagecontainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,15 @@ $.widget( "mobile.pagecontainer", {

return $.proxy( function( html, textStatus, xhr ) {

// Check that Content-Type is "text/html" (https://github.com/jquery/jquery-mobile/issues/8640)
if ( !/^text\/html\b/.test( xhr.getResponseHeader('Content-Type') ) ) {
// Display error message for unsupported content type
if ( settings.showLoadMsg ) {
this._showError();
}
return;
}

// Pre-parse html to check for a data-url, use it as the new fileUrl, base path, etc
var content,

Expand Down