jquery.ui.dialog-1.13.0-backport.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Backport of security fixes from:
  3. * https://bugs.jqueryui.com/ticket/6016
  4. * https://github.com/jquery/jquery-ui/pull/1635/files
  5. */
  6. (function ($) {
  7. // Parts of this backport differ by jQuery version.
  8. var versionParts = $.ui.dialog.version.split('.');
  9. var majorVersion = parseInt(versionParts[0]);
  10. var minorVersion = parseInt(versionParts[1]);
  11. if (majorVersion === 1 && minorVersion < 13) {
  12. var _originalSetOption = $.ui.dialog.prototype._setOption;
  13. var _originalCreateTitlebar = $.ui.dialog.prototype._createTitlebar;
  14. $.extend($.ui.dialog.prototype, {
  15. _createTitlebar: function () {
  16. if (this.options.closeText) {
  17. this.options.closeText = Drupal.checkPlain(this.options.closeText);
  18. }
  19. _originalCreateTitlebar.apply(this, arguments);
  20. },
  21. _setOption: function (key, value) {
  22. if (key === 'title' || key == 'closeText') {
  23. if (value) {
  24. value = Drupal.checkPlain(value);
  25. }
  26. }
  27. _originalSetOption.apply(this, [key, value]);
  28. }
  29. });
  30. if (majorVersion === 1 && minorVersion < 10) {
  31. var _originalCreate = $.ui.dialog.prototype._create;
  32. $.extend($.ui.dialog.prototype, {
  33. _create: function () {
  34. if (!this.options.title) {
  35. var defaultTitle = this.element.attr('title');
  36. // .attr() might return a DOMElement
  37. if (typeof defaultTitle !== "string") {
  38. defaultTitle = "";
  39. }
  40. this.options.title = defaultTitle;
  41. }
  42. this.options.title = Drupal.checkPlain(this.options.title);
  43. _originalCreate.apply(this, arguments);
  44. },
  45. });
  46. }
  47. }
  48. })(jQuery);