CVE-2023-33194 (published 2023-05-26T21:15Z)

Craft is a CMS for creating custom digital experiences on the web.The platform does not filter input and encode output in Quick Post validation error message, which can deliver an XSS payload. Old CVE fixed the XSS in label HTML but didn’t fix it when clicking save. This issue was patched in version 4.4.6.

CVSS v3 base score: 4.8, MEDIUM (CVSS:3.1/AV:N/AC:L/PR:H/UI:R/S:C/C:L/I:L/A:N)

Weakness information:
cwe_id: CWE-79
cwe_name: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
description: The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.
extended_description: 
            Cross-site scripting (XSS) vulnerabilities occur when:
            
               Untrusted data enters a web application, typically from a web request.
               The web application dynamically generates a web page that contains this untrusted data.
               During page generation, the application does not prevent the data from containing content that is executable by a web browser, such as JavaScript, HTML tags, HTML attributes, mouse events, Flash, ActiveX, etc.
               A victim visits the generated web page through a web browser, which contains malicious script that was injected using the untrusted data.
               Since the script comes from a web page that was sent by the web server, the victim's web browser executes the malicious script in the context of the web server's domain.
               This effectively violates the intention of the web browser's same-origin policy, which states that scripts in one domain should not be able to access resources or run code in a different domain.
            
            There are three main kinds of XSS:
            
               
                  Type 1: Reflected XSS (or Non-Persistent) - 
         			The server reads data directly from the HTTP request and reflects it back in the HTTP response. Reflected XSS exploits occur when an attacker causes a victim to supply dangerous content to a vulnerable web application, which is then reflected back to the victim and executed by the web browser. The most common mechanism for delivering malicious content is to include it as a parameter in a URL that is posted publicly or e-mailed directly to the victim. URLs constructed in this manner constitute the core of many phishing schemes, whereby an attacker convinces a victim to visit a URL that refers to a vulnerable site. After the site reflects the attacker's content back to the victim, the content is executed by the victim's browser.
               
                  Type 2: Stored XSS (or Persistent) - 
               The application stores dangerous data in a database, message forum, visitor log, or other trusted data store. At a later time, the dangerous data is subsequently read back into the application and included in dynamic content. From an attacker's perspective, the optimal place to inject malicious content is in an area that is displayed to either many users or particularly interesting users. Interesting users typically have elevated privileges in the application or interact with sensitive data that is valuable to the attacker. If one of these users executes malicious content, the attacker may be able to perform privileged operations on behalf of the user or gain access to sensitive data belonging to the user. For example, the attacker might inject XSS into a log message, which might not be handled properly when an administrator views the logs.
            
               
                  Type 0: DOM-Based XSS - 
               In DOM-based XSS, the client performs the injection of XSS into the page; in the other types, the server performs the injection. DOM-based XSS generally involves server-controlled, trusted script that is sent to the client, such as Javascript that performs sanity checks on a form before the user submits it. If the server-supplied script processes user-supplied data and then injects it back into the web page (such as with dynamic HTML), then DOM-based XSS is possible.
            
            
            Once the malicious script is injected, the attacker can perform a variety of malicious activities. The attacker could transfer private information, such as cookies that may include session information, from the victim's machine to the attacker. The attacker could send malicious requests to a web site on behalf of the victim, which could be especially dangerous to the site if the victim has administrator privileges to manage that site. Phishing attacks could be used to emulate trusted web sites and trick the victim into entering a password, allowing the attacker to compromise the victim's account on that web site. Finally, the script could exploit a vulnerability in the web browser itself possibly taking over the victim's machine, sometimes referred to as "drive-by hacking."
            In many cases, the attack can be launched without the victim even being aware of it. Even with careful users, attackers frequently use a variety of methods to encode the malicious portion of the attack, such as URL encoding or Unicode, so the request looks less suspicious.
         
         

Fix information:
repo_url: https://github.com/craftcms/cms
commit_details: repo_url: https://github.com/craftcms/cms
author: brandonkelly
author_date: 2023-04-03 16:48:46-07:00
msg: Fixed an XSS vulnerability
repository: repo_url: https://github.com/craftcms/cms
repo_name: craftcms/cms
description: Build bespoke content experiences with Craft.
repo_language: PHP
owner: craftcms
file_changes: filename: CHANGELOG.md
change_type: ModificationType.MODIFY
diff: @@ -11,6 +11,7 @@
 - Fixed a JavaScript error that occurred when closing a disclosure menu within Live Preview. ([#12992](https://github.com/craftcms/cms/issues/12992))
 - Fixed a bug where assets were getting relocated to the root volume folder when renamed. ([#12995](https://github.com/craftcms/cms/issues/12995))
 - Fixed a bug where it wasn’t possible to preview entries on another domain when the system was offline. ([#12979](https://github.com/craftcms/cms/issues/12979))
+- Fixed an XSS vulnerability.
 
 ## 3.8.5 - 2023-03-21
 

programming_language: Markdown
filename: QuickPostWidget.js
change_type: ModificationType.MODIFY
diff: @@ -1,2 +1,2 @@
-!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li>"+o+"</li>").appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
+!function(){var t;t=jQuery,Craft.QuickPostWidget=Garnish.Base.extend({params:null,initFields:null,formHtml:null,$widget:null,$form:null,$spinner:null,$errorList:null,loading:!1,init:function(i,r,e,n){this.params=r,this.initFields=e,this.formHtml=n,this.$widget=t("#widget"+i),this.initForm(this.$widget.find("form:first"))},initForm:function(t){this.$form=t,this.$spinner=this.$form.find(".spinner"),this.initFields();var i=this.$form.find("> .buttons > .btngroup > .menubtn"),r=i.data("menubtn").menu.$container.find("> ul > li > a");i.menubtn(),this.addListener(this.$form,"submit","handleFormSubmit"),this.addListener(r,"click","saveAndContinueEditing")},handleFormSubmit:function(t){t.preventDefault(),this.save(this.onSave.bind(this))},saveAndContinueEditing:function(){this.save(this.gotoEntry.bind(this))},save:function(i){var r=this;if(!this.loading){this.loading=!0,this.$spinner.removeClass("hidden");var e=Garnish.getPostData(this.$form),n=t.extend({enabled:1},e,this.params);Craft.postActionRequest("entries/save-entry",n,(function(e,n){if(r.loading=!1,r.$spinner.addClass("hidden"),r.$errorList&&r.$errorList.children().remove(),"success"===n)if(e.success)Craft.cp.displayNotice(Craft.t("app","Entry saved.")),i(e);else if(Craft.cp.displayError(Craft.t("app","Couldn’t save entry.")),e.errors)for(var s in r.$errorList||(r.$errorList=t('<ul class="errors"/>').insertAfter(r.$form)),e.errors)if(e.errors.hasOwnProperty(s))for(var a=0;a<e.errors[s].length;a++){var o=e.errors[s][a];t("<li/>",{text:o}).appendTo(r.$errorList)}}))}},onSave:function(i){var r=t(this.formHtml);if(this.$form.replaceWith(r),Craft.initUiElements(r),this.initForm(r),void 0!==Craft.RecentEntriesWidget)for(var e=0;e<Craft.RecentEntriesWidget.instances.length;e++){var n=Craft.RecentEntriesWidget.instances[e];n.params.sectionId&&n.params.sectionId!=this.params.sectionId||n.addEntry({url:i.cpEditUrl,title:i.title,dateCreated:i.dateCreated,username:i.authorUsername})}},gotoEntry:function(t){Craft.redirectTo(t.cpEditUrl)}})}();
 //# sourceMappingURL=QuickPostWidget.js.map
\ No newline at end of file

programming_language: JavaScript
filename: QuickPostWidget.js.map
change_type: ModificationType.MODIFY
diff: @@ -1 +1 @@
-{"version":3,"file":"QuickPostWidget.js","mappings":"YAAA,IAAWA,EAAAA,EAyIRC,OAtIDC,MAAMC,gBAAkBC,QAAQC,KAAKC,OAAO,CAC1CC,OAAQ,KACRC,WAAY,KACZC,SAAU,KACVC,QAAS,KACTC,MAAO,KACPC,SAAU,KACVC,WAAY,KACZC,SAAS,EAETC,KAAM,SAAUC,EAAUT,EAAQC,EAAYC,GAC5CQ,KAAKV,OAASA,EACdU,KAAKT,WAAaA,EAClBS,KAAKR,SAAWA,EAChBQ,KAAKP,QAAUV,EAAE,UAAYgB,GAE7BC,KAAKC,SAASD,KAAKP,QAAQS,KAAK,gBAGlCD,SAAU,SAAUP,GAClBM,KAAKN,MAAQA,EACbM,KAAKL,SAAWK,KAAKN,MAAMQ,KAAK,YAEhCF,KAAKT,aAEL,IAAIY,EAAWH,KAAKN,MAAMQ,KAAK,qCAC7BE,EAA6BD,EAC1BE,KAAK,WACLC,KAAKC,WAAWL,KAAK,iBAE1BC,EAASK,UAETR,KAAKS,YAAYT,KAAKN,MAAO,SAAU,oBACvCM,KAAKS,YACHL,EACA,QACA,2BAIJM,iBAAkB,SAAUC,GAC1BA,EAAMC,iBAENZ,KAAKa,KAAKb,KAAKc,OAAOC,KAAKf,QAG7BgB,uBAAwB,WACtBhB,KAAKa,KAAKb,KAAKiB,UAAUF,KAAKf,QAGhCa,KAAM,SAAUK,GAAU,WACxB,IAAIlB,KAAKH,QAAT,CAIAG,KAAKH,SAAU,EACfG,KAAKL,SAASwB,YAAY,UAE1B,IAAIC,EAAWjC,QAAQkC,YAAYrB,KAAKN,OACtCW,EAAOtB,EAAEM,OAAO,CAACiC,QAAS,GAAIF,EAAUpB,KAAKV,QAE/CL,MAAMsC,kBACJ,qBACAlB,GACA,SAACmB,EAAUC,GAQT,GAPA,EAAK5B,SAAU,EACf,EAAKF,SAAS+B,SAAS,UAEnB,EAAK9B,YACP,EAAKA,WAAW+B,WAAWC,SAGV,YAAfH,EACF,GAAID,EAASK,QACX5C,MAAM6C,GAAGC,cAAc9C,MAAM+C,EAAE,MAAO,iBACtCd,EAASM,QAIT,GAFAvC,MAAM6C,GAAGG,aAAahD,MAAM+C,EAAE,MAAO,yBAEjCR,EAASU,OAOX,IAAK,IAAIC,KANJ,EAAKvC,aACR,EAAKA,WAAab,EAAE,wBAAwBqD,YAC1C,EAAK1C,QAIa8B,EAASU,OAC7B,GAAKV,EAASU,OAAOG,eAAeF,GAIpC,IAAK,IAAIG,EAAI,EAAGA,EAAId,EAASU,OAAOC,GAAWI,OAAQD,IAAK,CAC1D,IAAIE,EAAQhB,EAASU,OAAOC,GAAWG,GACvCvD,EAAE,OAASyD,EAAQ,SAASC,SAAS,EAAK7C,kBAU1DkB,OAAQ,SAAUU,GAEhB,IAAIkB,EAAW3D,EAAEiB,KAAKR,UAMtB,GALAQ,KAAKN,MAAMiD,YAAYD,GACvBzD,MAAM2D,eAAeF,GACrB1C,KAAKC,SAASyC,QAG2B,IAA9BzD,MAAM4D,oBACf,IAAK,IAAIP,EAAI,EAAGA,EAAIrD,MAAM4D,oBAAoBC,UAAUP,OAAQD,IAAK,CACnE,IAAIS,EAAS9D,MAAM4D,oBAAoBC,UAAUR,GAE9CS,EAAOzD,OAAO0D,WACfD,EAAOzD,OAAO0D,WAAahD,KAAKV,OAAO0D,WAEvCD,EAAOE,SAAS,CACdC,IAAK1B,EAAS2B,UACdC,MAAO5B,EAAS4B,MAChBC,YAAa7B,EAAS6B,YACtBC,SAAU9B,EAAS+B,mBAO7BtC,UAAW,SAAUO,GAEnBvC,MAAMuE,WAAWhC,EAAS2B,c","sources":["webpack:///./QuickPostWidget.js"],"sourcesContent":["(function ($) {\n  /** global: Craft */\n  /** global: Garnish */\n  Craft.QuickPostWidget = Garnish.Base.extend({\n    params: null,\n    initFields: null,\n    formHtml: null,\n    $widget: null,\n    $form: null,\n    $spinner: null,\n    $errorList: null,\n    loading: false,\n\n    init: function (widgetId, params, initFields, formHtml) {\n      this.params = params;\n      this.initFields = initFields;\n      this.formHtml = formHtml;\n      this.$widget = $('#widget' + widgetId);\n\n      this.initForm(this.$widget.find('form:first'));\n    },\n\n    initForm: function ($form) {\n      this.$form = $form;\n      this.$spinner = this.$form.find('.spinner');\n\n      this.initFields();\n\n      var $menuBtn = this.$form.find('> .buttons > .btngroup > .menubtn'),\n        $saveAndContinueEditingBtn = $menuBtn\n          .data('menubtn')\n          .menu.$container.find('> ul > li > a');\n\n      $menuBtn.menubtn();\n\n      this.addListener(this.$form, 'submit', 'handleFormSubmit');\n      this.addListener(\n        $saveAndContinueEditingBtn,\n        'click',\n        'saveAndContinueEditing'\n      );\n    },\n\n    handleFormSubmit: function (event) {\n      event.preventDefault();\n\n      this.save(this.onSave.bind(this));\n    },\n\n    saveAndContinueEditing: function () {\n      this.save(this.gotoEntry.bind(this));\n    },\n\n    save: function (callback) {\n      if (this.loading) {\n        return;\n      }\n\n      this.loading = true;\n      this.$spinner.removeClass('hidden');\n\n      var formData = Garnish.getPostData(this.$form),\n        data = $.extend({enabled: 1}, formData, this.params);\n\n      Craft.postActionRequest(\n        'entries/save-entry',\n        data,\n        (response, textStatus) => {\n          this.loading = false;\n          this.$spinner.addClass('hidden');\n\n          if (this.$errorList) {\n            this.$errorList.children().remove();\n          }\n\n          if (textStatus === 'success') {\n            if (response.success) {\n              Craft.cp.displayNotice(Craft.t('app', 'Entry saved.'));\n              callback(response);\n            } else {\n              Craft.cp.displayError(Craft.t('app', 'Couldn’t save entry.'));\n\n              if (response.errors) {\n                if (!this.$errorList) {\n                  this.$errorList = $('<ul class=\"errors\"/>').insertAfter(\n                    this.$form\n                  );\n                }\n\n                for (var attribute in response.errors) {\n                  if (!response.errors.hasOwnProperty(attribute)) {\n                    continue;\n                  }\n\n                  for (var i = 0; i < response.errors[attribute].length; i++) {\n                    var error = response.errors[attribute][i];\n                    $('<li>' + error + '</li>').appendTo(this.$errorList);\n                  }\n                }\n              }\n            }\n          }\n        }\n      );\n    },\n\n    onSave: function (response) {\n      // Reset the widget\n      var $newForm = $(this.formHtml);\n      this.$form.replaceWith($newForm);\n      Craft.initUiElements($newForm);\n      this.initForm($newForm);\n\n      // Are there any Recent Entries widgets to notify?\n      if (typeof Craft.RecentEntriesWidget !== 'undefined') {\n        for (var i = 0; i < Craft.RecentEntriesWidget.instances.length; i++) {\n          var widget = Craft.RecentEntriesWidget.instances[i];\n          if (\n            !widget.params.sectionId ||\n            widget.params.sectionId == this.params.sectionId\n          ) {\n            widget.addEntry({\n              url: response.cpEditUrl,\n              title: response.title,\n              dateCreated: response.dateCreated,\n              username: response.authorUsername,\n            });\n          }\n        }\n      }\n    },\n\n    gotoEntry: function (response) {\n      // Redirect to the entry's edit URL\n      Craft.redirectTo(response.cpEditUrl);\n    },\n  });\n})(jQuery);\n"],"names":["$","jQuery","Craft","QuickPostWidget","Garnish","Base","extend","params","initFields","formHtml","$widget","$form","$spinner","$errorList","loading","init","widgetId","this","initForm","find","$menuBtn","$saveAndContinueEditingBtn","data","menu","$container","menubtn","addListener","handleFormSubmit","event","preventDefault","save","onSave","bind","saveAndContinueEditing","gotoEntry","callback","removeClass","formData","getPostData","enabled","postActionRequest","response","textStatus","addClass","children","remove","success","cp","displayNotice","t","displayError","errors","attribute","insertAfter","hasOwnProperty","i","length","error","appendTo","$newForm","replaceWith","initUiElements","RecentEntriesWidget","instances","widget","sectionId","addEntry","url","cpEditUrl","title","dateCreated","username","authorUsername","redirectTo"],"sourceRoot":""}
\ No newline at end of file
+{"version":3,"file":"QuickPostWidget.js","mappings":"YAAA,IAAWA,EAAAA,EA2IRC,OAxIDC,MAAMC,gBAAkBC,QAAQC,KAAKC,OAAO,CAC1CC,OAAQ,KACRC,WAAY,KACZC,SAAU,KACVC,QAAS,KACTC,MAAO,KACPC,SAAU,KACVC,WAAY,KACZC,SAAS,EAETC,KAAM,SAAUC,EAAUT,EAAQC,EAAYC,GAC5CQ,KAAKV,OAASA,EACdU,KAAKT,WAAaA,EAClBS,KAAKR,SAAWA,EAChBQ,KAAKP,QAAUV,EAAE,UAAYgB,GAE7BC,KAAKC,SAASD,KAAKP,QAAQS,KAAK,gBAGlCD,SAAU,SAAUP,GAClBM,KAAKN,MAAQA,EACbM,KAAKL,SAAWK,KAAKN,MAAMQ,KAAK,YAEhCF,KAAKT,aAEL,IAAIY,EAAWH,KAAKN,MAAMQ,KAAK,qCAC7BE,EAA6BD,EAC1BE,KAAK,WACLC,KAAKC,WAAWL,KAAK,iBAE1BC,EAASK,UAETR,KAAKS,YAAYT,KAAKN,MAAO,SAAU,oBACvCM,KAAKS,YACHL,EACA,QACA,2BAIJM,iBAAkB,SAAUC,GAC1BA,EAAMC,iBAENZ,KAAKa,KAAKb,KAAKc,OAAOC,KAAKf,QAG7BgB,uBAAwB,WACtBhB,KAAKa,KAAKb,KAAKiB,UAAUF,KAAKf,QAGhCa,KAAM,SAAUK,GAAU,WACxB,IAAIlB,KAAKH,QAAT,CAIAG,KAAKH,SAAU,EACfG,KAAKL,SAASwB,YAAY,UAE1B,IAAIC,EAAWjC,QAAQkC,YAAYrB,KAAKN,OACtCW,EAAOtB,EAAEM,OAAO,CAACiC,QAAS,GAAIF,EAAUpB,KAAKV,QAE/CL,MAAMsC,kBACJ,qBACAlB,GACA,SAACmB,EAAUC,GAQT,GAPA,EAAK5B,SAAU,EACf,EAAKF,SAAS+B,SAAS,UAEnB,EAAK9B,YACP,EAAKA,WAAW+B,WAAWC,SAGV,YAAfH,EACF,GAAID,EAASK,QACX5C,MAAM6C,GAAGC,cAAc9C,MAAM+C,EAAE,MAAO,iBACtCd,EAASM,QAIT,GAFAvC,MAAM6C,GAAGG,aAAahD,MAAM+C,EAAE,MAAO,yBAEjCR,EAASU,OAOX,IAAK,IAAIC,KANJ,EAAKvC,aACR,EAAKA,WAAab,EAAE,wBAAwBqD,YAC1C,EAAK1C,QAIa8B,EAASU,OAC7B,GAAKV,EAASU,OAAOG,eAAeF,GAIpC,IAAK,IAAIG,EAAI,EAAGA,EAAId,EAASU,OAAOC,GAAWI,OAAQD,IAAK,CAC1D,IAAIE,EAAQhB,EAASU,OAAOC,GAAWG,GACvCvD,EAAE,QAAS,CACT0D,KAAMD,IACLE,SAAS,EAAK9C,kBAUjCkB,OAAQ,SAAUU,GAEhB,IAAImB,EAAW5D,EAAEiB,KAAKR,UAMtB,GALAQ,KAAKN,MAAMkD,YAAYD,GACvB1D,MAAM4D,eAAeF,GACrB3C,KAAKC,SAAS0C,QAG2B,IAA9B1D,MAAM6D,oBACf,IAAK,IAAIR,EAAI,EAAGA,EAAIrD,MAAM6D,oBAAoBC,UAAUR,OAAQD,IAAK,CACnE,IAAIU,EAAS/D,MAAM6D,oBAAoBC,UAAUT,GAE9CU,EAAO1D,OAAO2D,WACfD,EAAO1D,OAAO2D,WAAajD,KAAKV,OAAO2D,WAEvCD,EAAOE,SAAS,CACdC,IAAK3B,EAAS4B,UACdC,MAAO7B,EAAS6B,MAChBC,YAAa9B,EAAS8B,YACtBC,SAAU/B,EAASgC,mBAO7BvC,UAAW,SAAUO,GAEnBvC,MAAMwE,WAAWjC,EAAS4B,c","sources":["webpack:///./QuickPostWidget.js"],"sourcesContent":["(function ($) {\n  /** global: Craft */\n  /** global: Garnish */\n  Craft.QuickPostWidget = Garnish.Base.extend({\n    params: null,\n    initFields: null,\n    formHtml: null,\n    $widget: null,\n    $form: null,\n    $spinner: null,\n    $errorList: null,\n    loading: false,\n\n    init: function (widgetId, params, initFields, formHtml) {\n      this.params = params;\n      this.initFields = initFields;\n      this.formHtml = formHtml;\n      this.$widget = $('#widget' + widgetId);\n\n      this.initForm(this.$widget.find('form:first'));\n    },\n\n    initForm: function ($form) {\n      this.$form = $form;\n      this.$spinner = this.$form.find('.spinner');\n\n      this.initFields();\n\n      var $menuBtn = this.$form.find('> .buttons > .btngroup > .menubtn'),\n        $saveAndContinueEditingBtn = $menuBtn\n          .data('menubtn')\n          .menu.$container.find('> ul > li > a');\n\n      $menuBtn.menubtn();\n\n      this.addListener(this.$form, 'submit', 'handleFormSubmit');\n      this.addListener(\n        $saveAndContinueEditingBtn,\n        'click',\n        'saveAndContinueEditing'\n      );\n    },\n\n    handleFormSubmit: function (event) {\n      event.preventDefault();\n\n      this.save(this.onSave.bind(this));\n    },\n\n    saveAndContinueEditing: function () {\n      this.save(this.gotoEntry.bind(this));\n    },\n\n    save: function (callback) {\n      if (this.loading) {\n        return;\n      }\n\n      this.loading = true;\n      this.$spinner.removeClass('hidden');\n\n      var formData = Garnish.getPostData(this.$form),\n        data = $.extend({enabled: 1}, formData, this.params);\n\n      Craft.postActionRequest(\n        'entries/save-entry',\n        data,\n        (response, textStatus) => {\n          this.loading = false;\n          this.$spinner.addClass('hidden');\n\n          if (this.$errorList) {\n            this.$errorList.children().remove();\n          }\n\n          if (textStatus === 'success') {\n            if (response.success) {\n              Craft.cp.displayNotice(Craft.t('app', 'Entry saved.'));\n              callback(response);\n            } else {\n              Craft.cp.displayError(Craft.t('app', 'Couldn’t save entry.'));\n\n              if (response.errors) {\n                if (!this.$errorList) {\n                  this.$errorList = $('<ul class=\"errors\"/>').insertAfter(\n                    this.$form\n                  );\n                }\n\n                for (var attribute in response.errors) {\n                  if (!response.errors.hasOwnProperty(attribute)) {\n                    continue;\n                  }\n\n                  for (var i = 0; i < response.errors[attribute].length; i++) {\n                    var error = response.errors[attribute][i];\n                    $('<li/>', {\n                      text: error,\n                    }).appendTo(this.$errorList);\n                  }\n                }\n              }\n            }\n          }\n        }\n      );\n    },\n\n    onSave: function (response) {\n      // Reset the widget\n      var $newForm = $(this.formHtml);\n      this.$form.replaceWith($newForm);\n      Craft.initUiElements($newForm);\n      this.initForm($newForm);\n\n      // Are there any Recent Entries widgets to notify?\n      if (typeof Craft.RecentEntriesWidget !== 'undefined') {\n        for (var i = 0; i < Craft.RecentEntriesWidget.instances.length; i++) {\n          var widget = Craft.RecentEntriesWidget.instances[i];\n          if (\n            !widget.params.sectionId ||\n            widget.params.sectionId == this.params.sectionId\n          ) {\n            widget.addEntry({\n              url: response.cpEditUrl,\n              title: response.title,\n              dateCreated: response.dateCreated,\n              username: response.authorUsername,\n            });\n          }\n        }\n      }\n    },\n\n    gotoEntry: function (response) {\n      // Redirect to the entry's edit URL\n      Craft.redirectTo(response.cpEditUrl);\n    },\n  });\n})(jQuery);\n"],"names":["$","jQuery","Craft","QuickPostWidget","Garnish","Base","extend","params","initFields","formHtml","$widget","$form","$spinner","$errorList","loading","init","widgetId","this","initForm","find","$menuBtn","$saveAndContinueEditingBtn","data","menu","$container","menubtn","addListener","handleFormSubmit","event","preventDefault","save","onSave","bind","saveAndContinueEditing","gotoEntry","callback","removeClass","formData","getPostData","enabled","postActionRequest","response","textStatus","addClass","children","remove","success","cp","displayNotice","t","displayError","errors","attribute","insertAfter","hasOwnProperty","i","length","error","text","appendTo","$newForm","replaceWith","initUiElements","RecentEntriesWidget","instances","widget","sectionId","addEntry","url","cpEditUrl","title","dateCreated","username","authorUsername","redirectTo"],"sourceRoot":""}
\ No newline at end of file

programming_language: JavaScript
filename: QuickPostWidget.js
change_type: ModificationType.MODIFY
diff: @@ -94,7 +94,9 @@
 
                   for (var i = 0; i < response.errors[attribute].length; i++) {
                     var error = response.errors[attribute][i];
-                    $('<li>' + error + '</li>').appendTo(this.$errorList);
+                    $('<li/>', {
+                      text: error,
+                    }).appendTo(this.$errorList);
                   }
                 }
               }

programming_language: JavaScript