Skip to content

Commit 7e9060c

Browse files
committed
Dialog: Extract setting the title into a _title method, use .text() to prevent XSS. Fixes #6016 - Dialog: Title XSS Vulnerability.
1 parent 60486ac commit 7e9060c

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

ui/jquery.ui.dialog.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,21 @@ $.widget("ui.dialog", {
352352
uiDialogTitle = $( "<span>" )
353353
.uniqueId()
354354
.addClass( "ui-dialog-title" )
355-
.html( this.options.title || "&#160;" )
356355
.prependTo( this.uiDialogTitlebar );
356+
this._title( uiDialogTitle );
357357

358358
this.uiDialog.attr({
359359
"aria-labelledby": uiDialogTitle.attr( "id" )
360360
});
361361
},
362362

363+
_title: function( title ) {
364+
if ( !this.options.title ) {
365+
title.html( "&#160;" );
366+
}
367+
title.text( this.options.title );
368+
},
369+
363370
_createButtonPane: function() {
364371
var uiDialogButtonPane = ( this.uiDialogButtonPane = $( "<div>" ) )
365372
.addClass( "ui-dialog-buttonpane ui-widget-content ui-helper-clearfix" );
@@ -600,9 +607,7 @@ $.widget("ui.dialog", {
600607
}
601608

602609
if ( key === "title" ) {
603-
// convert whatever was passed in to a string, for html() to not throw up
604-
$( ".ui-dialog-title", this.uiDialogTitlebar )
605-
.html( "" + ( value || "&#160;" ) );
610+
this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
606611
}
607612
},
608613

0 commit comments

Comments
 (0)