From 1647b11bf458079a6d56df5d6885752e56e1610c Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 19 Sep 2017 10:15:32 +0000 Subject: [PATCH] Editor: Prevent adding `javascript:` and `data:` URLs through the inline link dialog. Merge of [41393] to the 4.8 branch. Built from https://develop.svn.wordpress.org/branches/4.8@41400 git-svn-id: http://core.svn.wordpress.org/branches/4.8@41233 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../js/tinymce/plugins/wplink/plugin.js | 9 ++++++++- .../js/tinymce/plugins/wplink/plugin.min.js | 2 +- wp-includes/js/tinymce/wp-tinymce.js.gz | Bin 200292 -> 200338 bytes wp-includes/js/wplink.js | 16 +++++++++++++++- wp-includes/js/wplink.min.js | 2 +- wp-includes/version.php | 2 +- 6 files changed, 26 insertions(+), 5 deletions(-) diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.js b/wp-includes/js/tinymce/plugins/wplink/plugin.js index a874e61091..2a7f697368 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.js @@ -4,7 +4,7 @@ renderHtml: function() { return ( '' ); }, @@ -249,6 +249,13 @@ text = inputInstance.getLinkText(); editor.focus(); + var parser = document.createElement( 'a' ); + parser.href = href; + + if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line + href = ''; + } + if ( ! href ) { editor.dom.remove( linkNode, true ); return; diff --git a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js index 365b5b5fb2..fb4f708919 100644 --- a/wp-includes/js/tinymce/plugins/wplink/plugin.min.js +++ b/wp-includes/js/tinymce/plugins/wplink/plugin.min.js @@ -1 +1 @@ -!function(a){a.ui.Factory.add("WPLinkPreview",a.ui.Control.extend({url:"#",renderHtml:function(){return'"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),(c=b.indexOf("?"))!==-1&&(b=b.slice(0,c)),(c=b.indexOf("#"))!==-1&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&(c=b.indexOf("/"))!==-1&&(d=b.lastIndexOf("/"))!==-1&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}})),a.ui.Factory.add("WPLinkInput",a.ui.Control.extend({renderHtml:function(){return''},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){return a.trim(this.getEl().firstChild.value)},getLinkText:function(){var b=this.getEl().firstChild.nextSibling.value;return a.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){var a=this.getEl().firstChild;a.value="",a.nextSibling.value=""}})),a.PluginManager.add("wplink",function(b){function c(){var a,c,d=b.selection.getStart(),e=b.dom.getParent(d,"a[href]");return e||(c=b.selection.getContent({format:"raw"}),c&&c.indexOf("")!==-1&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&b.selection.select(e))),e}function d(){b.$("a").each(function(a,c){var d=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}function e(a,b){return a.replace(/(]+>)([\s\S]*?)<\/a>/g,function(a,c,d){return c.indexOf(' href="_wp_link_placeholder"')>-1?d:(b&&(c=c.replace(/ data-wplink-edit="true"/g,"")),c=c.replace(/ data-wplink-url-error="true"/g,""),c+d+"")})}function f(a){var c=b.$(a),d=c.attr("href");d&&"undefined"!=typeof n&&(s=!1,!/^http/i.test(d)||p.test(d)&&q.test(d)?c.removeAttr("data-wplink-url-error"):(s=!0,c.attr("data-wplink-url-error","true"),r(b.translate("Warning: the link has been inserted but may have errors. Please test it."),"assertive")))}var g,h,i,j,k,l,m,n=window.jQuery,o=/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i,p=/^https?:\/\/([^\s\/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i,q=/^https?:\/\/[^\/]+\.[^\/]+($|\/)/i,r="undefined"!=typeof window.wp&&window.wp.a11y&&window.wp.a11y.speak?window.wp.a11y.speak:function(){},s=!1;return b.on("preinit",function(){if(b.wp&&b.wp._createToolbar){g=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0);var a=["wp_link_input","wp_link_apply"];"undefined"!=typeof window.wpLink&&a.push("wp_link_advanced"),h=b.wp._createToolbar(a,!0),h.on("show",function(){"undefined"!=typeof window.wpLink&&window.wpLink.modalOpen||window.setTimeout(function(){var a=h.$el.find("input.ui-autocomplete-input")[0],b=k&&(k.textContent||k.innerText);a&&(!a.value&&b&&"undefined"!=typeof window.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),l||(a.focus(),a.select()))})}),h.on("hide",function(){h.scrolling||b.execCommand("wp_link_cancel")})}}),b.addCommand("WP_Link",function(){return a.Env.ie&&a.Env.ie<10&&"undefined"!=typeof window.wpLink?void window.wpLink.open(b.id):(k=c(),h.tempHide=!1,void(k?b.dom.setAttribs(k,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),k=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!h.scrolling){var c,d;if(k){if(c=j.getURL(),d=j.getLinkText(),b.focus(),!c)return void b.dom.remove(k,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)||o.test(c)||(c="http://"+c),b.dom.setAttribs(k,{href:c,"data-wplink-edit":null}),a.trim(k.innerHTML)||b.$(k).text(d||c),f(k)}j.reset(),b.nodeChanged(),"undefined"==typeof window.wpLinkL10n||s||r(window.wpLinkL10n.linkInserted)}}),b.addCommand("wp_link_cancel",function(){h.tempHide||(j.reset(),d())}),b.addCommand("wp_unlink",function(){b.execCommand("unlink"),h.tempHide=!1,b.execCommand("wp_link_cancel")}),b.addShortcut("access+a","","WP_Link"),b.addShortcut("access+s","","wp_unlink"),b.addShortcut("meta+k","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.on("savecontent",function(a){a.content=e(a.content,!0)}),b.on("BeforeAddUndo",function(a){a.lastLevel&&a.lastLevel.content&&a.level.content&&a.lastLevel.content===e(a.level.content)&&a.preventDefault()}),b.on("keydown",function(c){27===c.keyCode&&b.execCommand("wp_link_cancel"),c.altKey||a.Env.mac&&(!c.metaKey||c.ctrlKey)||!a.Env.mac&&!c.ctrlKey||89!==c.keyCode&&90!==c.keyCode||(l=!0,window.clearTimeout(m),m=window.setTimeout(function(){l=!1},500))}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){i=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e,f=this.getEl(),g=f.firstChild;j=this,n&&n.ui&&n.ui.autocomplete&&(c=n(g),c.on("keydown",function(){c.removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return e===a.term?void b(d):/^https?:/.test(a.term)||a.term.indexOf(".")!==-1?b():(n.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:n("#_ajax_linking_nonce").val()},function(a){d=a,b(a)},"json"),void(e=a.term))},focus:function(a,b){c.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID),a.preventDefault()},select:function(a,b){return c.val(b.item.permalink),n(f.firstChild.nextSibling).val(b.item.title),9===a.keyCode&&"undefined"!=typeof window.wpLinkL10n&&r(window.wpLinkL10n.linkSelected),!1},open:function(){c.attr("aria-expanded","true"),h.blockHide=!0},close:function(){c.attr("aria-expanded","false"),h.blockHide=!1},minLength:2,position:{my:"left top+2"},messages:{noResults:"undefined"!=typeof window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(a){if("undefined"!=typeof window.uiAutocompleteL10n)return a>1?window.uiAutocompleteL10n.manyResults.replace("%d",a):window.uiAutocompleteL10n.oneResult}}}).autocomplete("instance")._renderItem=function(a,b){return n('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},c.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":c.autocomplete("widget").attr("id")}).on("focus",function(){var a=c.val();a&&!/^https?:/.test(a)&&c.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox").removeAttr("tabindex").on("menufocus",function(a,b){b.item.attr("aria-selected","true")}).on("menublur",function(){n(this).find('[aria-selected="true"]').removeAttr("aria-selected")})),a.$(g).on("keydown",function(a){13===a.keyCode&&(b.execCommand("wp_link_apply"),a.preventDefault())})}}),b.on("wptoolbar",function(a){var c,d,e,f=b.dom.getParent(a.element,"a");return"undefined"!=typeof window.wpLink&&window.wpLink.modalOpen?void(h.tempHide=!0):(h.tempHide=!1,void(f?(c=b.$(f),d=c.attr("href"),e=c.attr("data-wplink-edit"),"_wp_link_placeholder"===d||e?("_wp_link_placeholder"===d||j.getURL()||j.setURL(d),a.element=f,a.toolbar=h):d&&!c.find("img").length&&(i.setURL(d),a.element=f,a.toolbar=g,"true"===c.attr("data-wplink-url-error")?g.$el.find(".wp-link-preview a").addClass("wplink-url-error"):(g.$el.find(".wp-link-preview a").removeClass("wplink-url-error"),s=!1))):h.visible()&&b.execCommand("wp_link_cancel")))}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove link",icon:"dashicon dashicons-editor-unlink",cmd:"wp_unlink"}),b.addButton("wp_link_advanced",{tooltip:"Link options",icon:"dashicon dashicons-admin-generic",onclick:function(){if("undefined"!=typeof window.wpLink){var c=j.getURL()||null,d=j.getLinkText()||null;a.Env.ie&&b.focus(),h.tempHide=!0,window.wpLink.open(b.id,c,d,k),j.reset()}}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){h.tempHide=!1,b.execCommand("wp_link_cancel")},checkLink:f}})}(window.tinymce); \ No newline at end of file +!function(a){a.ui.Factory.add("WPLinkPreview",a.ui.Control.extend({url:"#",renderHtml:function(){return'"},setURL:function(b){var c,d;this.url!==b&&(this.url=b,b=window.decodeURIComponent(b),b=b.replace(/^(?:https?:)?\/\/(?:www\.)?/,""),(c=b.indexOf("?"))!==-1&&(b=b.slice(0,c)),(c=b.indexOf("#"))!==-1&&(b=b.slice(0,c)),b=b.replace(/(?:index)?\.html$/,""),"/"===b.charAt(b.length-1)&&(b=b.slice(0,-1)),""===b&&(b=this.url),b.length>40&&(c=b.indexOf("/"))!==-1&&(d=b.lastIndexOf("/"))!==-1&&d!==c&&(c+b.length-d<40&&(d=-(40-(c+1))),b=b.slice(0,c+1)+"\u2026"+b.slice(d)),a.$(this.getEl().firstChild).attr("href",this.url).text(b))}})),a.ui.Factory.add("WPLinkInput",a.ui.Control.extend({renderHtml:function(){return''},setURL:function(a){this.getEl().firstChild.value=a},getURL:function(){return a.trim(this.getEl().firstChild.value)},getLinkText:function(){var b=this.getEl().firstChild.nextSibling.value;return a.trim(b)?b.replace(/[\r\n\t ]+/g," "):""},reset:function(){var a=this.getEl().firstChild;a.value="",a.nextSibling.value=""}})),a.PluginManager.add("wplink",function(b){function c(){var a,c,d=b.selection.getStart(),e=b.dom.getParent(d,"a[href]");return e||(c=b.selection.getContent({format:"raw"}),c&&c.indexOf("")!==-1&&(a=c.match(/href="([^">]+)"/),a&&a[1]&&(e=b.$('a[href="'+a[1]+'"]',d)[0]),e&&b.selection.select(e))),e}function d(){b.$("a").each(function(a,c){var d=b.$(c);"_wp_link_placeholder"===d.attr("href")?b.dom.remove(c,!0):d.attr("data-wplink-edit")&&d.attr("data-wplink-edit",null)})}function e(a,b){return a.replace(/(]+>)([\s\S]*?)<\/a>/g,function(a,c,d){return c.indexOf(' href="_wp_link_placeholder"')>-1?d:(b&&(c=c.replace(/ data-wplink-edit="true"/g,"")),c=c.replace(/ data-wplink-url-error="true"/g,""),c+d+"")})}function f(a){var c=b.$(a),d=c.attr("href");d&&"undefined"!=typeof n&&(s=!1,!/^http/i.test(d)||p.test(d)&&q.test(d)?c.removeAttr("data-wplink-url-error"):(s=!0,c.attr("data-wplink-url-error","true"),r(b.translate("Warning: the link has been inserted but may have errors. Please test it."),"assertive")))}var g,h,i,j,k,l,m,n=window.jQuery,o=/^(mailto:)?[a-z0-9._%+-]+@[a-z0-9][a-z0-9.-]*\.[a-z]{2,63}$/i,p=/^https?:\/\/([^\s\/?.#-][^\s\/?.#]*\.?)+(\/[^\s"]*)?$/i,q=/^https?:\/\/[^\/]+\.[^\/]+($|\/)/i,r="undefined"!=typeof window.wp&&window.wp.a11y&&window.wp.a11y.speak?window.wp.a11y.speak:function(){},s=!1;return b.on("preinit",function(){if(b.wp&&b.wp._createToolbar){g=b.wp._createToolbar(["wp_link_preview","wp_link_edit","wp_link_remove"],!0);var a=["wp_link_input","wp_link_apply"];"undefined"!=typeof window.wpLink&&a.push("wp_link_advanced"),h=b.wp._createToolbar(a,!0),h.on("show",function(){"undefined"!=typeof window.wpLink&&window.wpLink.modalOpen||window.setTimeout(function(){var a=h.$el.find("input.ui-autocomplete-input")[0],b=k&&(k.textContent||k.innerText);a&&(!a.value&&b&&"undefined"!=typeof window.wpLink&&(a.value=window.wpLink.getUrlFromSelection(b)),l||(a.focus(),a.select()))})}),h.on("hide",function(){h.scrolling||b.execCommand("wp_link_cancel")})}}),b.addCommand("WP_Link",function(){return a.Env.ie&&a.Env.ie<10&&"undefined"!=typeof window.wpLink?void window.wpLink.open(b.id):(k=c(),h.tempHide=!1,void(k?b.dom.setAttribs(k,{"data-wplink-edit":!0}):(d(),b.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder"}),k=b.$('a[href="_wp_link_placeholder"]')[0],b.nodeChanged())))}),b.addCommand("wp_link_apply",function(){if(!h.scrolling){var c,d;if(k){c=j.getURL(),d=j.getLinkText(),b.focus();var e=document.createElement("a");if(e.href=c,"javascript:"!==e.protocol&&"data:"!==e.protocol||(c=""),!c)return void b.dom.remove(k,!0);/^(?:[a-z]+:|#|\?|\.|\/)/.test(c)||o.test(c)||(c="http://"+c),b.dom.setAttribs(k,{href:c,"data-wplink-edit":null}),a.trim(k.innerHTML)||b.$(k).text(d||c),f(k)}j.reset(),b.nodeChanged(),"undefined"==typeof window.wpLinkL10n||s||r(window.wpLinkL10n.linkInserted)}}),b.addCommand("wp_link_cancel",function(){h.tempHide||(j.reset(),d())}),b.addCommand("wp_unlink",function(){b.execCommand("unlink"),h.tempHide=!1,b.execCommand("wp_link_cancel")}),b.addShortcut("access+a","","WP_Link"),b.addShortcut("access+s","","wp_unlink"),b.addShortcut("meta+k","","WP_Link"),b.addButton("link",{icon:"link",tooltip:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]"}),b.addButton("unlink",{icon:"unlink",tooltip:"Remove link",cmd:"unlink"}),b.addMenuItem("link",{icon:"link",text:"Insert/edit link",cmd:"WP_Link",stateSelector:"a[href]",context:"insert",prependToContext:!0}),b.on("pastepreprocess",function(c){var d=c.content,e=/^(?:https?:)?\/\/\S+$/i;b.selection.isCollapsed()||e.test(b.selection.getContent())||(d=d.replace(/<[^>]+>/g,""),d=a.trim(d),e.test(d)&&(b.execCommand("mceInsertLink",!1,{href:b.dom.decode(d)}),c.preventDefault()))}),b.on("savecontent",function(a){a.content=e(a.content,!0)}),b.on("BeforeAddUndo",function(a){a.lastLevel&&a.lastLevel.content&&a.level.content&&a.lastLevel.content===e(a.level.content)&&a.preventDefault()}),b.on("keydown",function(c){27===c.keyCode&&b.execCommand("wp_link_cancel"),c.altKey||a.Env.mac&&(!c.metaKey||c.ctrlKey)||!a.Env.mac&&!c.ctrlKey||89!==c.keyCode&&90!==c.keyCode||(l=!0,window.clearTimeout(m),m=window.setTimeout(function(){l=!1},500))}),b.addButton("wp_link_preview",{type:"WPLinkPreview",onPostRender:function(){i=this}}),b.addButton("wp_link_input",{type:"WPLinkInput",onPostRender:function(){var c,d,e,f=this.getEl(),g=f.firstChild;j=this,n&&n.ui&&n.ui.autocomplete&&(c=n(g),c.on("keydown",function(){c.removeAttr("aria-activedescendant")}).autocomplete({source:function(a,b){return e===a.term?void b(d):/^https?:/.test(a.term)||a.term.indexOf(".")!==-1?b():(n.post(window.ajaxurl,{action:"wp-link-ajax",page:1,search:a.term,_ajax_linking_nonce:n("#_ajax_linking_nonce").val()},function(a){d=a,b(a)},"json"),void(e=a.term))},focus:function(a,b){c.attr("aria-activedescendant","mce-wp-autocomplete-"+b.item.ID),a.preventDefault()},select:function(a,b){return c.val(b.item.permalink),n(f.firstChild.nextSibling).val(b.item.title),9===a.keyCode&&"undefined"!=typeof window.wpLinkL10n&&r(window.wpLinkL10n.linkSelected),!1},open:function(){c.attr("aria-expanded","true"),h.blockHide=!0},close:function(){c.attr("aria-expanded","false"),h.blockHide=!1},minLength:2,position:{my:"left top+2"},messages:{noResults:"undefined"!=typeof window.uiAutocompleteL10n?window.uiAutocompleteL10n.noResults:"",results:function(a){if("undefined"!=typeof window.uiAutocompleteL10n)return a>1?window.uiAutocompleteL10n.manyResults.replace("%d",a):window.uiAutocompleteL10n.oneResult}}}).autocomplete("instance")._renderItem=function(a,b){return n('
  • ').append(""+b.title+' '+b.info+"").appendTo(a)},c.attr({role:"combobox","aria-autocomplete":"list","aria-expanded":"false","aria-owns":c.autocomplete("widget").attr("id")}).on("focus",function(){var a=c.val();a&&!/^https?:/.test(a)&&c.autocomplete("search")}).autocomplete("widget").addClass("wplink-autocomplete").attr("role","listbox").removeAttr("tabindex").on("menufocus",function(a,b){b.item.attr("aria-selected","true")}).on("menublur",function(){n(this).find('[aria-selected="true"]').removeAttr("aria-selected")})),a.$(g).on("keydown",function(a){13===a.keyCode&&(b.execCommand("wp_link_apply"),a.preventDefault())})}}),b.on("wptoolbar",function(a){var c,d,e,f=b.dom.getParent(a.element,"a");return"undefined"!=typeof window.wpLink&&window.wpLink.modalOpen?void(h.tempHide=!0):(h.tempHide=!1,void(f?(c=b.$(f),d=c.attr("href"),e=c.attr("data-wplink-edit"),"_wp_link_placeholder"===d||e?("_wp_link_placeholder"===d||j.getURL()||j.setURL(d),a.element=f,a.toolbar=h):d&&!c.find("img").length&&(i.setURL(d),a.element=f,a.toolbar=g,"true"===c.attr("data-wplink-url-error")?g.$el.find(".wp-link-preview a").addClass("wplink-url-error"):(g.$el.find(".wp-link-preview a").removeClass("wplink-url-error"),s=!1))):h.visible()&&b.execCommand("wp_link_cancel")))}),b.addButton("wp_link_edit",{tooltip:"Edit ",icon:"dashicon dashicons-edit",cmd:"WP_Link"}),b.addButton("wp_link_remove",{tooltip:"Remove link",icon:"dashicon dashicons-editor-unlink",cmd:"wp_unlink"}),b.addButton("wp_link_advanced",{tooltip:"Link options",icon:"dashicon dashicons-admin-generic",onclick:function(){if("undefined"!=typeof window.wpLink){var c=j.getURL()||null,d=j.getLinkText()||null;a.Env.ie&&b.focus(),h.tempHide=!0,window.wpLink.open(b.id,c,d,k),j.reset()}}}),b.addButton("wp_link_apply",{tooltip:"Apply",icon:"dashicon dashicons-editor-break",cmd:"wp_link_apply",classes:"widget btn primary"}),{close:function(){h.tempHide=!1,b.execCommand("wp_link_cancel")},checkLink:f}})}(window.tinymce); \ No newline at end of file diff --git a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m;VL32~t?2`{%=-B($Am4Mk|u^AWnvy7oF7-8$eh}Ly9Ucg(^8c5#qzHV1T9($ZbOe}47)b$5Mo^8DnI zYSJ#$jCQ(G(k2)RD{Q3P!R)0=+u9c|4Aw5B zQL@@gvCbbcV&+BpV7L^G`Ni%Qz6=z?&aOGRR3_LVwn5FX- zkuTRp*Z*^oN**4OyRX@`H-i&;UB~`&!CUn0m%%VupFVZbFr-)}V?*++GA0HFSz}4= z%xHNWm-d$2RoBrDII!RnIS?IshTGzmtkp}YL@yBN0{4SCAnp)N_dlq?B$tm%`6xvK clz6Y+BaC|N5IpRILWs`(Kiv0;=|67?06RycNB{r; diff --git a/wp-includes/js/wplink.js b/wp-includes/js/wplink.js index 652ed688a3..ca2b394438 100644 --- a/wp-includes/js/wplink.js +++ b/wp-includes/js/wplink.js @@ -312,7 +312,7 @@ var wpLink; var html = ''; @@ -337,6 +337,13 @@ var wpLink; attrs = wpLink.getAttrs(); text = inputs.text.val(); + var parser = document.createElement( 'a' ); + parser.href = attrs.href; + + if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line + attrs.href = ''; + } + // If there's no href, return. if ( ! attrs.href ) { return; @@ -390,6 +397,13 @@ var wpLink; var attrs = wpLink.getAttrs(), $link, text, hasText, $mceCaret; + var parser = document.createElement( 'a' ); + parser.href = attrs.href; + + if ( 'javascript:' === parser.protocol || 'data:' === parser.protocol ) { // jshint ignore:line + attrs.href = ''; + } + if ( ! attrs.href ) { editor.execCommand( 'unlink' ); wpLink.close(); diff --git a/wp-includes/js/wplink.min.js b/wp-includes/js/wplink.min.js index e5a7ecaa11..f8175d6e80 100644 --- a/wp-includes/js/wplink.min.js +++ b/wp-includes/js/wplink.min.js @@ -1 +1 @@ -var wpLink;!function(a,b,c){function d(){return j||e.dom.getParent(e.selection.getNode(),"a[href]")}var e,f,g,h,i,j,k=/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,63}$/i,l=/^(https?|ftp):\/\/[A-Z0-9.-]+\.[A-Z]{2,63}[^ "]*$/i,m={},n={},o="ontouchend"in document;wpLink={timeToTriggerRiver:150,minRiverAJAXDuration:200,riverBottomThreshold:5,keySensitivity:100,lastSearch:"",textarea:"",modalOpen:!1,init:function(){m.wrap=a("#wp-link-wrap"),m.dialog=a("#wp-link"),m.backdrop=a("#wp-link-backdrop"),m.submit=a("#wp-link-submit"),m.close=a("#wp-link-close"),m.text=a("#wp-link-text"),m.url=a("#wp-link-url"),m.nonce=a("#_ajax_linking_nonce"),m.openInNewTab=a("#wp-link-target"),m.search=a("#wp-link-search"),n.search=new g(a("#search-results")),n.recent=new g(a("#most-recent-results")),n.elements=m.dialog.find(".query-results"),m.queryNotice=a("#query-notice-message"),m.queryNoticeTextDefault=m.queryNotice.find(".query-notice-default"),m.queryNoticeTextHint=m.queryNotice.find(".query-notice-hint"),m.dialog.keydown(wpLink.keydown),m.dialog.keyup(wpLink.keyup),m.submit.click(function(a){a.preventDefault(),wpLink.update()}),m.close.add(m.backdrop).add("#wp-link-cancel button").click(function(a){a.preventDefault(),wpLink.close()}),n.elements.on("river-select",wpLink.updateFields),m.search.on("focus.wplink",function(){m.queryNoticeTextDefault.hide(),m.queryNoticeTextHint.removeClass("screen-reader-text").show()}).on("blur.wplink",function(){m.queryNoticeTextDefault.show(),m.queryNoticeTextHint.addClass("screen-reader-text").hide()}),m.search.on("keyup input",function(){window.clearTimeout(f),f=window.setTimeout(function(){wpLink.searchInternalLinks()},500)}),m.url.on("paste",function(){setTimeout(wpLink.correctURL,0)}),m.url.on("blur",wpLink.correctURL)},correctURL:function(){var b=a.trim(m.url.val());b&&i!==b&&!/^(?:[a-z]+:|#|\?|\.|\/)/.test(b)&&(m.url.val("http://"+b),i=b)},open:function(b,c,d,f){var g,h=a(document.body);h.addClass("modal-open"),wpLink.modalOpen=!0,j=f,wpLink.range=null,b&&(window.wpActiveEditor=b),window.wpActiveEditor&&(this.textarea=a("#"+window.wpActiveEditor).get(0),"undefined"!=typeof window.tinymce&&(h.append(m.backdrop,m.wrap),g=window.tinymce.get(window.wpActiveEditor),e=g&&!g.isHidden()?g:null),!wpLink.isMCE()&&document.selection&&(this.textarea.focus(),this.range=document.selection.createRange()),m.wrap.show(),m.backdrop.show(),wpLink.refresh(c,d),a(document).trigger("wplink-open",m.wrap))},isMCE:function(){return e&&!e.isHidden()},refresh:function(a,b){var c="";n.search.refresh(),n.recent.refresh(),wpLink.isMCE()?wpLink.mceRefresh(a,b):(m.wrap.hasClass("has-text-field")||m.wrap.addClass("has-text-field"),document.selection?c=document.selection.createRange().text||b||"":"undefined"!=typeof this.textarea.selectionStart&&this.textarea.selectionStart!==this.textarea.selectionEnd&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd)||b||""),m.text.val(b),wpLink.setDefaultValues()),o?m.url.focus().blur():window.setTimeout(function(){m.url[0].select(),m.url.focus()}),n.recent.ul.children().length||n.recent.ajax(),i=m.url.val().replace(/^http:\/\//,"")},hasSelectedText:function(a){var b,c,d,f=e.selection.getContent();if(/]+>[^<]+<\/a>$/.test(f)||f.indexOf("href=")===-1))return!1;if(a){if(c=a.childNodes,0===c.length)return!1;for(d=c.length-1;d>=0;d--)if(b=c[d],3!=b.nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(c,f){var g,h,i=d(),j=this.hasSelectedText(i);i?(g=i.textContent||i.innerText,h=e.dom.getAttrib(i,"href"),a.trim(g)||(g=f||""),c&&(l.test(c)||k.test(c))&&(h=c),"_wp_link_placeholder"!==h?(m.url.val(h),m.openInNewTab.prop("checked","_blank"===e.dom.getAttrib(i,"target")),m.submit.val(b.update)):this.setDefaultValues(g),c&&c!==h?m.search.val(c):m.search.val(""),window.setTimeout(function(){wpLink.searchInternalLinks()})):(g=e.selection.getContent({format:"text"})||f||"",this.setDefaultValues(g)),j?(m.text.val(g),m.wrap.addClass("has-text-field")):(m.text.val(""),m.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),wpLink.modalOpen=!1,"noReset"!==b&&(wpLink.isMCE()?(e.plugins.wplink&&e.plugins.wplink.close(),e.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),m.backdrop.hide(),m.wrap.hide(),i=!1,a(document).trigger("wplink-close",m.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(m.url.val()),target:m.openInNewTab.prop("checked")?"_blank":null}},buildHtml:function(a){var b='"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var d,e,f,g,h,i,j,k=wpLink.textarea;k&&(d=wpLink.getAttrs(),e=m.text.val(),d.href&&(f=wpLink.buildHtml(d),document.selection&&wpLink.range?(k.focus(),wpLink.range.text=f+(e||wpLink.range.text)+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof k.selectionStart&&(g=k.selectionStart,h=k.selectionEnd,j=e||k.value.substring(g,h),f=f+j+"",i=g+f.length,g!==h||j||(i-=4),k.value=k.value.substring(0,g)+f+k.value.substring(h,k.value.length),k.selectionStart=k.selectionEnd=i),wpLink.close(),k.focus(),a(k).trigger("change"),c.a11y.speak(b.linkInserted)))},mceUpdate:function(){var f,g,h,i,j=wpLink.getAttrs();return j.href?(f=e.$(d()),e.undoManager.transact(function(){f.length||(e.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder","data-wp-temp-link":1}),f=e.$('a[data-wp-temp-link="1"]').removeAttr("data-wp-temp-link"),h=a.trim(f.text())),f.length?(m.wrap.hasClass("has-text-field")&&(g=m.text.val(),g?f.text(g):h||f.text(j.href)),j["data-wplink-edit"]=null,j["data-mce-href"]=null,f.attr(j)):e.execCommand("unlink")}),wpLink.close("noReset"),e.focus(),f.length&&(i=f.parent("#_mce_caret"),i.length&&i.before(f.removeAttr("data-mce-bogus")),e.selection.select(f[0]),e.selection.collapse(),e.plugins.wplink&&e.plugins.wplink.checkLink(f[0])),e.nodeChanged(),void c.a11y.speak(b.linkInserted)):(e.execCommand("unlink"),void wpLink.close())},updateFields:function(a,b){m.url.val(b.children(".item-permalink").val())},getUrlFromSelection:function(b){return b||(this.isMCE()?b=e.selection.getContent({format:"text"}):document.selection&&wpLink.range?b=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),b=a.trim(b),b&&k.test(b)?"mailto:"+b:b&&l.test(b)?b.replace(/&|�?38;/gi,"&"):""},setDefaultValues:function(a){m.url.val(this.getUrlFromSelection(a)),m.search.val(""),wpLink.searchInternalLinks(),m.submit.val(b.save)},searchInternalLinks:function(){var a,b=m.search.val()||"";if(b.length>2){if(n.recent.hide(),n.search.show(),wpLink.lastSearch==b)return;wpLink.lastSearch=b,a=m.search.parent().find(".spinner").addClass("is-active"),n.search.change(b),n.search.ajax(function(){a.removeClass("is-active")})}else n.search.hide(),n.recent.show()},next:function(){n.search.next(),n.recent.next()},prev:function(){n.search.prev(),n.recent.prev()},keydown:function(a){var b,c;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(c=a.target.id,"wp-link-submit"!==c||a.shiftKey?"wp-link-close"===c&&a.shiftKey&&(m.submit.focus(),a.preventDefault()):(m.close.focus(),a.preventDefault())),38!==a.keyCode&&40!==a.keyCode||(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(b=38===a.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[b](),wpLink.keyInterval=setInterval(wpLink[b],wpLink.keySensitivity),a.preventDefault())},keyup:function(a){38!==a.keyCode&&40!==a.keyCode||(clearInterval(wpLink.keyInterval),a.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a}},g=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(g.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),e<0?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new h(a),this.element.scrollTop(0))},process:function(c,d){var e="",f=!0,g="",h=1==d.page;c?a.each(c,function(){g=f?"alternate":"",g+=this.title?"":" no-title",e+=g?'
  • ':"
  • ",e+='',e+='',e+=this.title?this.title:b.noTitle,e+=''+this.info+"
  • ",f=!f}):h&&(e+='
  • '+b.noMatchesFound+"
  • "),this.ul[h?"html":"append"](e)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c]+>[^<]+<\/a>$/.test(f)||f.indexOf("href=")===-1))return!1;if(a){if(c=a.childNodes,0===c.length)return!1;for(d=c.length-1;d>=0;d--)if(b=c[d],3!=b.nodeType&&!window.tinymce.dom.BookmarkManager.isBookmarkNode(b))return!1}return!0},mceRefresh:function(c,f){var g,h,i=d(),j=this.hasSelectedText(i);i?(g=i.textContent||i.innerText,h=e.dom.getAttrib(i,"href"),a.trim(g)||(g=f||""),c&&(l.test(c)||k.test(c))&&(h=c),"_wp_link_placeholder"!==h?(m.url.val(h),m.openInNewTab.prop("checked","_blank"===e.dom.getAttrib(i,"target")),m.submit.val(b.update)):this.setDefaultValues(g),c&&c!==h?m.search.val(c):m.search.val(""),window.setTimeout(function(){wpLink.searchInternalLinks()})):(g=e.selection.getContent({format:"text"})||f||"",this.setDefaultValues(g)),j?(m.text.val(g),m.wrap.addClass("has-text-field")):(m.text.val(""),m.wrap.removeClass("has-text-field"))},close:function(b){a(document.body).removeClass("modal-open"),wpLink.modalOpen=!1,"noReset"!==b&&(wpLink.isMCE()?(e.plugins.wplink&&e.plugins.wplink.close(),e.focus()):(wpLink.textarea.focus(),wpLink.range&&(wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select()))),m.backdrop.hide(),m.wrap.hide(),i=!1,a(document).trigger("wplink-close",m.wrap)},getAttrs:function(){return wpLink.correctURL(),{href:a.trim(m.url.val()),target:m.openInNewTab.prop("checked")?"_blank":null}},buildHtml:function(a){var b='"},update:function(){wpLink.isMCE()?wpLink.mceUpdate():wpLink.htmlUpdate()},htmlUpdate:function(){var d,e,f,g,h,i,j,k=wpLink.textarea;if(k){d=wpLink.getAttrs(),e=m.text.val();var l=document.createElement("a");l.href=d.href,"javascript:"!==l.protocol&&"data:"!==l.protocol||(d.href=""),d.href&&(f=wpLink.buildHtml(d),document.selection&&wpLink.range?(k.focus(),wpLink.range.text=f+(e||wpLink.range.text)+"",wpLink.range.moveToBookmark(wpLink.range.getBookmark()),wpLink.range.select(),wpLink.range=null):"undefined"!=typeof k.selectionStart&&(g=k.selectionStart,h=k.selectionEnd,j=e||k.value.substring(g,h),f=f+j+"",i=g+f.length,g!==h||j||(i-=4),k.value=k.value.substring(0,g)+f+k.value.substring(h,k.value.length),k.selectionStart=k.selectionEnd=i),wpLink.close(),k.focus(),a(k).trigger("change"),c.a11y.speak(b.linkInserted))}},mceUpdate:function(){var f,g,h,i,j=wpLink.getAttrs(),k=document.createElement("a");return k.href=j.href,"javascript:"!==k.protocol&&"data:"!==k.protocol||(j.href=""),j.href?(f=e.$(d()),e.undoManager.transact(function(){f.length||(e.execCommand("mceInsertLink",!1,{href:"_wp_link_placeholder","data-wp-temp-link":1}),f=e.$('a[data-wp-temp-link="1"]').removeAttr("data-wp-temp-link"),h=a.trim(f.text())),f.length?(m.wrap.hasClass("has-text-field")&&(g=m.text.val(),g?f.text(g):h||f.text(j.href)),j["data-wplink-edit"]=null,j["data-mce-href"]=null,f.attr(j)):e.execCommand("unlink")}),wpLink.close("noReset"),e.focus(),f.length&&(i=f.parent("#_mce_caret"),i.length&&i.before(f.removeAttr("data-mce-bogus")),e.selection.select(f[0]),e.selection.collapse(),e.plugins.wplink&&e.plugins.wplink.checkLink(f[0])),e.nodeChanged(),void c.a11y.speak(b.linkInserted)):(e.execCommand("unlink"),void wpLink.close())},updateFields:function(a,b){m.url.val(b.children(".item-permalink").val())},getUrlFromSelection:function(b){return b||(this.isMCE()?b=e.selection.getContent({format:"text"}):document.selection&&wpLink.range?b=wpLink.range.text:"undefined"!=typeof this.textarea.selectionStart&&(b=this.textarea.value.substring(this.textarea.selectionStart,this.textarea.selectionEnd))),b=a.trim(b),b&&k.test(b)?"mailto:"+b:b&&l.test(b)?b.replace(/&|�?38;/gi,"&"):""},setDefaultValues:function(a){m.url.val(this.getUrlFromSelection(a)),m.search.val(""),wpLink.searchInternalLinks(),m.submit.val(b.save)},searchInternalLinks:function(){var a,b=m.search.val()||"";if(b.length>2){if(n.recent.hide(),n.search.show(),wpLink.lastSearch==b)return;wpLink.lastSearch=b,a=m.search.parent().find(".spinner").addClass("is-active"),n.search.change(b),n.search.ajax(function(){a.removeClass("is-active")})}else n.search.hide(),n.recent.show()},next:function(){n.search.next(),n.recent.next()},prev:function(){n.search.prev(),n.recent.prev()},keydown:function(a){var b,c;27===a.keyCode?(wpLink.close(),a.stopImmediatePropagation()):9===a.keyCode&&(c=a.target.id,"wp-link-submit"!==c||a.shiftKey?"wp-link-close"===c&&a.shiftKey&&(m.submit.focus(),a.preventDefault()):(m.close.focus(),a.preventDefault())),38!==a.keyCode&&40!==a.keyCode||(!document.activeElement||"link-title-field"!==document.activeElement.id&&"url-field"!==document.activeElement.id)&&(b=38===a.keyCode?"prev":"next",clearInterval(wpLink.keyInterval),wpLink[b](),wpLink.keyInterval=setInterval(wpLink[b],wpLink.keySensitivity),a.preventDefault())},keyup:function(a){38!==a.keyCode&&40!==a.keyCode||(clearInterval(wpLink.keyInterval),a.preventDefault())},delayedCallback:function(a,b){var c,d,e,f;return b?(setTimeout(function(){return d?a.apply(f,e):void(c=!0)},b),function(){return c?a.apply(this,arguments):(e=arguments,f=this,void(d=!0))}):a}},g=function(b,c){var d=this;this.element=b,this.ul=b.children("ul"),this.contentHeight=b.children("#link-selector-height"),this.waiting=b.find(".river-waiting"),this.change(c),this.refresh(),a("#wp-link .query-results, #wp-link #link-selector").scroll(function(){d.maybeLoad()}),b.on("click","li",function(b){d.select(a(this),b)})},a.extend(g.prototype,{refresh:function(){this.deselect(),this.visible=this.element.is(":visible")},show:function(){this.visible||(this.deselect(),this.element.show(),this.visible=!0)},hide:function(){this.element.hide(),this.visible=!1},select:function(a,b){var c,d,e,f;a.hasClass("unselectable")||a==this.selected||(this.deselect(),this.selected=a.addClass("selected"),c=a.outerHeight(),d=this.element.height(),e=a.position().top,f=this.element.scrollTop(),e<0?this.element.scrollTop(f+e):e+c>d&&this.element.scrollTop(f+e-d+c),this.element.trigger("river-select",[a,b,this]))},deselect:function(){this.selected&&this.selected.removeClass("selected"),this.selected=!1},prev:function(){if(this.visible){var a;this.selected&&(a=this.selected.prev("li"),a.length&&this.select(a))}},next:function(){if(this.visible){var b=this.selected?this.selected.next("li"):a("li:not(.unselectable):first",this.element);b.length&&this.select(b)}},ajax:function(a){var b=this,c=1==this.query.page?0:wpLink.minRiverAJAXDuration,d=wpLink.delayedCallback(function(c,d){b.process(c,d),a&&a(c,d)},c);this.query.ajax(d)},change:function(a){this.query&&this._search==a||(this._search=a,this.query=new h(a),this.element.scrollTop(0))},process:function(c,d){var e="",f=!0,g="",h=1==d.page;c?a.each(c,function(){g=f?"alternate":"",g+=this.title?"":" no-title",e+=g?'
  • ':"
  • ",e+='',e+='',e+=this.title?this.title:b.noTitle,e+=''+this.info+"
  • ",f=!f}):h&&(e+='
  • '+b.noMatchesFound+"
  • "),this.ul[h?"html":"append"](e)},maybeLoad:function(){var a=this,b=this.element,c=b.scrollTop()+b.height();!this.query.ready()||c