jquery-ui.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'jquery'
  7. ], function ($) {
  8. 'use strict';
  9. /**
  10. * Patch for CVE-2016-7103 (XSS vulnerability).
  11. * Can safely remove only when jQuery UI is upgraded to >= 1.12.x.
  12. * https://www.cvedetails.com/cve/CVE-2016-7103/
  13. */
  14. function dialogPatch() {
  15. $.widget('ui.dialog', $.ui.dialog, {
  16. /** @inheritdoc */
  17. _createTitlebar: function () {
  18. this.options.closeText = $('<a>').text('' + this.options.closeText).html();
  19. this._superApply();
  20. },
  21. /** @inheritdoc */
  22. _setOption: function (key, value) {
  23. if (key === 'closeText') {
  24. value = $('<a>').text('' + value).html();
  25. }
  26. this._super(key, value);
  27. }
  28. });
  29. }
  30. return function () {
  31. var majorVersion = $.ui.version.split('.')[0],
  32. minorVersion = $.ui.version.split('.')[1];
  33. if (majorVersion === 1 && minorVersion >= 12 || majorVersion >= 2) {
  34. console.warn('jQuery patch for CVE-2016-7103 is no longer necessary, and should be removed');
  35. }
  36. dialogPatch();
  37. };
  38. });