From cd3e85fe234a3505fd902dcb403e63b3f45fd598 Mon Sep 17 00:00:00 2001 From: desrosj Date: Thu, 18 Mar 2021 17:53:19 +0000 Subject: [PATCH] External Libraries: Update the jQuery Form library. This updates the `jquery-form` library from version `4.2.1` to `4.3.0`. A full list of changes can be found on GitHub: https://github.com/jquery-form/form/compare/v4.2.1...v4.3.0. Fixes #52685. Built from https://develop.svn.wordpress.org/trunk@50546 git-svn-id: http://core.svn.wordpress.org/trunk@50159 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/js/jquery/jquery.form.js | 48 +++++++++++++++++------- wp-includes/js/jquery/jquery.form.min.js | 2 +- wp-includes/version.php | 2 +- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/wp-includes/js/jquery/jquery.form.js b/wp-includes/js/jquery/jquery.form.js index bd9e2a5a5f..168d4b8b69 100644 --- a/wp-includes/js/jquery/jquery.form.js +++ b/wp-includes/js/jquery/jquery.form.js @@ -1,12 +1,23 @@ /*! * jQuery Form Plugin - * version: 4.2.1 - * Requires jQuery v1.7 or later + * version: 4.3.0 + * Requires jQuery v1.7.2 or later + * Project repository: https://github.com/jquery-form/form + * Copyright 2017 Kevin Morris * Copyright 2006 M. Alsup - * Project repository: https://github.com/jquery-form/form - * Dual licensed under the MIT and LGPLv3 licenses. + + * Dual licensed under the LGPL-2.1+ or MIT licenses * https://github.com/jquery-form/form#license + + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. */ /* global ActiveXObject */ @@ -125,7 +136,7 @@ } /* eslint consistent-this: ["error", "$form"] */ - var method, action, url, $form = this; + var method, action, url, isMsie, iframeSrc, $form = this; if (typeof options === 'function') { options = {success: options}; @@ -154,12 +165,16 @@ // clean url (don't include hash vaue) url = (url.match(/^([^#]+)/) || [])[1]; } + // IE requires javascript:false in https, but this breaks chrome >83 and goes against spec. + // Instead of using javascript:false always, let's only apply it for IE. + isMsie = /(MSIE|Trident)/.test(navigator.userAgent || ''); + iframeSrc = (isMsie && /^https/i.test(window.location.href || '')) ? 'javascript:false' : 'about:blank'; // eslint-disable-line no-script-url options = $.extend(true, { url : url, success : $.ajaxSettings.success, type : method || $.ajaxSettings.type, - iframeSrc : /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' // eslint-disable-line no-script-url + iframeSrc : iframeSrc }, options); // hook for manipulating the form data before it is extracted; @@ -654,12 +669,12 @@ // if using the $.param format that allows for multiple values with the same name if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) { extraInputs.push( - $('', ownerDocument).val(s.extraData[n].value) - .appendTo(form)[0]); + $('', ownerDocument).val(s.extraData[n].value) + .appendTo(form)[0]); } else { extraInputs.push( - $('', ownerDocument).val(s.extraData[n]) - .appendTo(form)[0]); + $('', ownerDocument).val(s.extraData[n]) + .appendTo(form)[0]); } } } @@ -725,7 +740,8 @@ return; - } else if (e === SERVER_ABORT && xhr) { + } + if (e === SERVER_ABORT && xhr) { xhr.abort('server abort'); deferred.reject(xhr, 'error', 'server abort'); @@ -1000,6 +1016,10 @@ return this; } + if (options.beforeFormUnbind) { + options.beforeFormUnbind(this, options); + } + return this.ajaxFormUnbind() .on('submit.form-plugin', options, doAjaxSubmit) .on('click.form-plugin', options, captureSubmittingElement); @@ -1394,7 +1414,7 @@ switch (tag) { case 'input': this.checked = this.defaultChecked; - // fall through + // fall through case 'textarea': this.value = this.defaultValue; @@ -1442,8 +1462,8 @@ return true; case 'form': - // guard against an input with the name of 'reset' - // note that IE reports the reset function as an 'object' + // guard against an input with the name of 'reset' + // note that IE reports the reset function as an 'object' if (typeof this.reset === 'function' || (typeof this.reset === 'object' && !this.reset.nodeType)) { this.reset(); } diff --git a/wp-includes/js/jquery/jquery.form.min.js b/wp-includes/js/jquery/jquery.form.min.js index 1cedb4d923..f033b25776 100644 --- a/wp-includes/js/jquery/jquery.form.min.js +++ b/wp-includes/js/jquery/jquery.form.min.js @@ -1 +1 @@ -!function(r){"function"==typeof define&&define.amd?define(["jquery"],r):"object"==typeof module&&module.exports?module.exports=function(e,t){return void 0===t&&(t="undefined"!=typeof window?require("jquery"):require("jquery")(e)),r(t),t}:r(jQuery)}(function(O){"use strict";var d=/\r?\n/g,v={};v.fileapi=void 0!==O('').get(0).files,v.formdata=void 0!==window.FormData;var X=!!O.fn.prop;function o(e){var t=e.data;e.isDefaultPrevented()||(e.preventDefault(),O(e.target).closest("form").ajaxSubmit(t))}function i(e){var t=e.target,r=O(t);if(!r.is("[type=submit],[type=image]")){var a=r.closest("[type=submit]");if(0===a.length)return;t=a[0]}var n=t.form;"image"===(n.clk=t).type&&(void 0!==e.offsetX?(n.clk_x=e.offsetX,n.clk_y=e.offsetY):"function"==typeof O.fn.offset?(r=r.offset(),n.clk_x=e.pageX-r.left,n.clk_y=e.pageY-r.top):(n.clk_x=e.pageX-t.offsetLeft,n.clk_y=e.pageY-t.offsetTop)),setTimeout(function(){n.clk=n.clk_x=n.clk_y=null},100)}function C(){var e;O.fn.ajaxSubmit.debug&&(e="[jquery.form] "+Array.prototype.join.call(arguments,""),window.console&&window.console.log?window.console.log(e):window.opera&&window.opera.postError&&window.opera.postError(e))}O.fn.attr2=function(){if(!X)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},O.fn.ajaxSubmit=function(F,e,t,r){if(!this.length)return C("ajaxSubmit: skipping submit process - no element selected"),this;var L,E=this;"function"==typeof F?F={success:F}:"string"==typeof F||!1===F&&0',s)).css({position:"absolute",top:"-1000px",left:"-1000px"}),d=f[0],p={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){var t="timeout"===e?"timeout":"aborted";C("aborting upload... "+t),this.aborted=1;try{d.contentWindow.document.execCommand&&d.contentWindow.document.execCommand("Stop")}catch(e){}f.attr("src",c.iframeSrc),p.error=t,c.error&&c.error.call(c.context,p,t,e),l&&O.event.trigger("ajaxError",[p,c,t]),c.complete&&c.complete.call(c.context,p,t)}},(l=c.global)&&0==O.active++&&O.event.trigger("ajaxStart"),l&&O.event.trigger("ajaxSend",[p,c]),c.beforeSend&&!1===c.beforeSend.call(c.context,p,c))return c.global&&O.active--,v.reject(),v;if(p.aborted)return v.reject(),v;(e=o.clk)&&(a=e.name)&&!e.disabled&&(c.extraData=c.extraData||{},c.extraData[a]=e.value,"image"===e.type&&(c.extraData[a+".x"]=o.clk_x,c.extraData[a+".y"]=o.clk_y));var g=1,x=2;function y(t){var r=null;try{t.contentWindow&&(r=t.contentWindow.document)}catch(e){C("cannot get iframe.contentWindow document: "+e)}if(r)return r;try{r=t.contentDocument||t.document}catch(e){C("cannot get iframe.contentDocument: "+e),r=t.document}return r}var e=O("meta[name=csrf-token]").attr("content"),a=O("meta[name=csrf-param]").attr("content");function n(){var e=E.attr2("target"),t=E.attr2("action"),r=E.attr("enctype")||E.attr("encoding")||"multipart/form-data";o.setAttribute("target",i),L&&!/post/i.test(L)||o.setAttribute("method","POST"),t!==c.url&&o.setAttribute("action",c.url),c.skipEncodingOverride||L&&!/post/i.test(L)||E.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),c.timeout&&(h=setTimeout(function(){m=!0,S(g)},c.timeout));var a=[];try{if(c.extraData)for(var n in c.extraData)c.extraData.hasOwnProperty(n)&&(O.isPlainObject(c.extraData[n])&&c.extraData[n].hasOwnProperty("name")&&c.extraData[n].hasOwnProperty("value")?a.push(O('',s).val(c.extraData[n].value).appendTo(o)[0]):a.push(O('',s).val(c.extraData[n]).appendTo(o)[0]));c.iframeTarget||f.appendTo(u),d.attachEvent?d.attachEvent("onload",S):d.addEventListener("load",S,!1),setTimeout(function e(){try{var t=y(d).readyState;C("state = "+t),t&&"uninitialized"===t.toLowerCase()&&setTimeout(e,50)}catch(e){C("Server abort: ",e," (",e.name,")"),S(x),h&&clearTimeout(h),h=void 0}},15);try{o.submit()}catch(e){document.createElement("form").submit.apply(o)}}finally{o.setAttribute("action",t),o.setAttribute("enctype",r),e?o.setAttribute("target",e):E.removeAttr("target"),O(a).remove()}}a&&e&&(c.extraData=c.extraData||{},c.extraData[a]=e),c.forceSync?n():setTimeout(n,10);var b,T,j,w=50;function S(t){if(!p.aborted&&!j){if((T=y(d))||(C("cannot access response document"),t=x),t===g&&p)return p.abort("timeout"),void v.reject(p,"timeout");if(t===x&&p)return p.abort("server abort"),void v.reject(p,"error","server abort");if(T&&T.location.href!==c.iframeSrc||m){d.detachEvent?d.detachEvent("onload",S):d.removeEventListener("load",S,!1);var r,t="success";try{if(m)throw"timeout";var e="xml"===c.dataType||T.XMLDocument||O.isXMLDoc(T);if(C("isXml="+e),!e&&window.opera&&(null===T.body||!T.body.innerHTML)&&--w)return C("requeing onLoad callback, DOM not available"),void setTimeout(S,250);var a=T.body||T.documentElement;p.responseText=a?a.innerHTML:null,p.responseXML=T.XMLDocument||T,e&&(c.dataType="xml"),p.getResponseHeader=function(e){return{"content-type":c.dataType}[e.toLowerCase()]},a&&(p.status=Number(a.getAttribute("status"))||p.status,p.statusText=a.getAttribute("statusText")||p.statusText);var n,o,i,s=(c.dataType||"").toLowerCase(),u=/(json|script|text)/.test(s);u||c.textarea?(n=T.getElementsByTagName("textarea")[0])?(p.responseText=n.value,p.status=Number(n.getAttribute("status"))||p.status,p.statusText=n.getAttribute("statusText")||p.statusText):u&&(o=T.getElementsByTagName("pre")[0],i=T.getElementsByTagName("body")[0],o?p.responseText=o.textContent||o.innerText:i&&(p.responseText=i.textContent||i.innerText)):"xml"===s&&!p.responseXML&&p.responseText&&(p.responseXML=k(p.responseText));try{b=A(p,s,c)}catch(e){t="parsererror",p.error=r=e||t}}catch(e){C("error caught: ",e),t="error",p.error=r=e||t}p.aborted&&(C("upload aborted"),t=null),"success"===(t=p.status?200<=p.status&&p.status<300||304===p.status?"success":"error":t)?(c.success&&c.success.call(c.context,b,"success",p),v.resolve(p.responseText,"success",p),l&&O.event.trigger("ajaxSuccess",[p,c])):t&&(void 0===r&&(r=p.statusText),c.error&&c.error.call(c.context,p,t,r),v.reject(p,"error",r),l&&O.event.trigger("ajaxError",[p,c,r])),l&&O.event.trigger("ajaxComplete",[p,c]),l&&!--O.active&&O.event.trigger("ajaxStop"),c.complete&&c.complete.call(c.context,p,t),j=!0,c.timeout&&clearTimeout(h),setTimeout(function(){c.iframeTarget?f.attr("src",c.iframeSrc):f.remove(),p.responseXML=null},100)}}}var k=O.parseXML||function(e,t){return window.ActiveXObject?((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!==t.documentElement.nodeName?t:null},D=O.parseJSON||function(e){return window.eval("("+e+")")},A=function(e,t,r){var a=e.getResponseHeader("content-type")||"",n=("xml"===t||!t)&&0<=a.indexOf("xml"),e=n?e.responseXML:e.responseText;return n&&"parsererror"===e.documentElement.nodeName&&O.error&&O.error("parsererror"),"string"==typeof(e=r&&r.dataFilter?r.dataFilter(e,t):e)&&(("json"===t||!t)&&0<=a.indexOf("json")?e=D(e):("script"===t||!t)&&0<=a.indexOf("javascript")&&O.globalEval(e)),e};return v}},O.fn.ajaxForm=function(e,t,r,a){if(("string"==typeof e||!1===e&&0').get(0).files,v.formdata=void 0!==window.FormData;var X=!!O.fn.prop;function o(e){var t=e.data;e.isDefaultPrevented()||(e.preventDefault(),O(e.target).closest("form").ajaxSubmit(t))}function i(e){var t=e.target,r=O(t);if(!r.is("[type=submit],[type=image]")){var a=r.closest("[type=submit]");if(0===a.length)return;t=a[0]}var n=t.form;"image"===(n.clk=t).type&&(void 0!==e.offsetX?(n.clk_x=e.offsetX,n.clk_y=e.offsetY):"function"==typeof O.fn.offset?(r=r.offset(),n.clk_x=e.pageX-r.left,n.clk_y=e.pageY-r.top):(n.clk_x=e.pageX-t.offsetLeft,n.clk_y=e.pageY-t.offsetTop)),setTimeout(function(){n.clk=n.clk_x=n.clk_y=null},100)}function C(){var e;O.fn.ajaxSubmit.debug&&(e="[jquery.form] "+Array.prototype.join.call(arguments,""),window.console&&window.console.log?window.console.log(e):window.opera&&window.opera.postError&&window.opera.postError(e))}O.fn.attr2=function(){if(!X)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},O.fn.ajaxSubmit=function(F,e,t,r){if(!this.length)return C("ajaxSubmit: skipping submit process - no element selected"),this;var E,L=this;"function"==typeof F?F={success:F}:"string"==typeof F||!1===F&&0',s)).css({position:"absolute",top:"-1000px",left:"-1000px"}),d=f[0],p={aborted:0,responseText:null,responseXML:null,status:0,statusText:"n/a",getAllResponseHeaders:function(){},getResponseHeader:function(){},setRequestHeader:function(){},abort:function(e){var t="timeout"===e?"timeout":"aborted";C("aborting upload... "+t),this.aborted=1;try{d.contentWindow.document.execCommand&&d.contentWindow.document.execCommand("Stop")}catch(e){}f.attr("src",c.iframeSrc),p.error=t,c.error&&c.error.call(c.context,p,t,e),l&&O.event.trigger("ajaxError",[p,c,t]),c.complete&&c.complete.call(c.context,p,t)}},(l=c.global)&&0==O.active++&&O.event.trigger("ajaxStart"),l&&O.event.trigger("ajaxSend",[p,c]),c.beforeSend&&!1===c.beforeSend.call(c.context,p,c))return c.global&&O.active--,v.reject(),v;if(p.aborted)return v.reject(),v;(e=o.clk)&&(a=e.name)&&!e.disabled&&(c.extraData=c.extraData||{},c.extraData[a]=e.value,"image"===e.type&&(c.extraData[a+".x"]=o.clk_x,c.extraData[a+".y"]=o.clk_y));var g=1,x=2;function y(t){var r=null;try{t.contentWindow&&(r=t.contentWindow.document)}catch(e){C("cannot get iframe.contentWindow document: "+e)}if(r)return r;try{r=t.contentDocument||t.document}catch(e){C("cannot get iframe.contentDocument: "+e),r=t.document}return r}var e=O("meta[name=csrf-token]").attr("content"),a=O("meta[name=csrf-param]").attr("content");function n(){var e=L.attr2("target"),t=L.attr2("action"),r=L.attr("enctype")||L.attr("encoding")||"multipart/form-data";o.setAttribute("target",i),E&&!/post/i.test(E)||o.setAttribute("method","POST"),t!==c.url&&o.setAttribute("action",c.url),c.skipEncodingOverride||E&&!/post/i.test(E)||L.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),c.timeout&&(h=setTimeout(function(){m=!0,S(g)},c.timeout));var a=[];try{if(c.extraData)for(var n in c.extraData)c.extraData.hasOwnProperty(n)&&(O.isPlainObject(c.extraData[n])&&c.extraData[n].hasOwnProperty("name")&&c.extraData[n].hasOwnProperty("value")?a.push(O('',s).val(c.extraData[n].value).appendTo(o)[0]):a.push(O('',s).val(c.extraData[n]).appendTo(o)[0]));c.iframeTarget||f.appendTo(u),d.attachEvent?d.attachEvent("onload",S):d.addEventListener("load",S,!1),setTimeout(function e(){try{var t=y(d).readyState;C("state = "+t),t&&"uninitialized"===t.toLowerCase()&&setTimeout(e,50)}catch(e){C("Server abort: ",e," (",e.name,")"),S(x),h&&clearTimeout(h),h=void 0}},15);try{o.submit()}catch(e){document.createElement("form").submit.apply(o)}}finally{o.setAttribute("action",t),o.setAttribute("enctype",r),e?o.setAttribute("target",e):L.removeAttr("target"),O(a).remove()}}a&&e&&(c.extraData=c.extraData||{},c.extraData[a]=e),c.forceSync?n():setTimeout(n,10);var b,T,j,w=50;function S(t){if(!p.aborted&&!j){if((T=y(d))||(C("cannot access response document"),t=x),t===g&&p)return p.abort("timeout"),void v.reject(p,"timeout");if(t===x&&p)return p.abort("server abort"),void v.reject(p,"error","server abort");if(T&&T.location.href!==c.iframeSrc||m){d.detachEvent?d.detachEvent("onload",S):d.removeEventListener("load",S,!1);var r,t="success";try{if(m)throw"timeout";var e="xml"===c.dataType||T.XMLDocument||O.isXMLDoc(T);if(C("isXml="+e),!e&&window.opera&&(null===T.body||!T.body.innerHTML)&&--w)return C("requeing onLoad callback, DOM not available"),void setTimeout(S,250);var a=T.body||T.documentElement;p.responseText=a?a.innerHTML:null,p.responseXML=T.XMLDocument||T,e&&(c.dataType="xml"),p.getResponseHeader=function(e){return{"content-type":c.dataType}[e.toLowerCase()]},a&&(p.status=Number(a.getAttribute("status"))||p.status,p.statusText=a.getAttribute("statusText")||p.statusText);var n,o,i,s=(c.dataType||"").toLowerCase(),u=/(json|script|text)/.test(s);u||c.textarea?(n=T.getElementsByTagName("textarea")[0])?(p.responseText=n.value,p.status=Number(n.getAttribute("status"))||p.status,p.statusText=n.getAttribute("statusText")||p.statusText):u&&(o=T.getElementsByTagName("pre")[0],i=T.getElementsByTagName("body")[0],o?p.responseText=o.textContent||o.innerText:i&&(p.responseText=i.textContent||i.innerText)):"xml"===s&&!p.responseXML&&p.responseText&&(p.responseXML=k(p.responseText));try{b=A(p,s,c)}catch(e){t="parsererror",p.error=r=e||t}}catch(e){C("error caught: ",e),t="error",p.error=r=e||t}p.aborted&&(C("upload aborted"),t=null),"success"===(t=p.status?200<=p.status&&p.status<300||304===p.status?"success":"error":t)?(c.success&&c.success.call(c.context,b,"success",p),v.resolve(p.responseText,"success",p),l&&O.event.trigger("ajaxSuccess",[p,c])):t&&(void 0===r&&(r=p.statusText),c.error&&c.error.call(c.context,p,t,r),v.reject(p,"error",r),l&&O.event.trigger("ajaxError",[p,c,r])),l&&O.event.trigger("ajaxComplete",[p,c]),l&&!--O.active&&O.event.trigger("ajaxStop"),c.complete&&c.complete.call(c.context,p,t),j=!0,c.timeout&&clearTimeout(h),setTimeout(function(){c.iframeTarget?f.attr("src",c.iframeSrc):f.remove(),p.responseXML=null},100)}}}var k=O.parseXML||function(e,t){return window.ActiveXObject?((t=new ActiveXObject("Microsoft.XMLDOM")).async="false",t.loadXML(e)):t=(new DOMParser).parseFromString(e,"text/xml"),t&&t.documentElement&&"parsererror"!==t.documentElement.nodeName?t:null},D=O.parseJSON||function(e){return window.eval("("+e+")")},A=function(e,t,r){var a=e.getResponseHeader("content-type")||"",n=("xml"===t||!t)&&0<=a.indexOf("xml"),e=n?e.responseXML:e.responseText;return n&&"parsererror"===e.documentElement.nodeName&&O.error&&O.error("parsererror"),"string"==typeof(e=r&&r.dataFilter?r.dataFilter(e,t):e)&&(("json"===t||!t)&&0<=a.indexOf("json")?e=D(e):("script"===t||!t)&&0<=a.indexOf("javascript")&&O.globalEval(e)),e};return v}},O.fn.ajaxForm=function(e,t,r,a){if(("string"==typeof e||!1===e&&0