From 7aba5362c65329acceb7654acf77de31eeb8bbeb Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Sun, 8 Sep 2019 10:17:12 +0200 Subject: [PATCH] Bug fix when select parent pages with special HTML characters. Related issue #1072 --- .../themes/booty/css/jquery-auto-complete.css | 43 +++++++++++++++---- .../booty/js/jquery-auto-complete.min.js | 10 +++-- bl-kernel/admin/views/edit-content.php | 2 +- bl-kernel/admin/views/new-content.php | 2 +- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/bl-kernel/admin/themes/booty/css/jquery-auto-complete.css b/bl-kernel/admin/themes/booty/css/jquery-auto-complete.css index 4261b1d0..d4916cf2 100755 --- a/bl-kernel/admin/themes/booty/css/jquery-auto-complete.css +++ b/bl-kernel/admin/themes/booty/css/jquery-auto-complete.css @@ -1,9 +1,36 @@ .autocomplete-suggestions { - text-align: left; cursor: default; border: 1px solid #ccc; border-top: 0; background: #fff; box-shadow: -1px 1px 3px rgba(0,0,0,.1); - - /* core styles should not be changed */ - position: absolute; display: none; z-index: 9999; max-height: 254px; overflow: hidden; overflow-y: auto; box-sizing: border-box; -} -.autocomplete-suggestion { position: relative; padding: 0 .6em; line-height: 23px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 1.02em; color: #333; } -.autocomplete-suggestion b { font-weight: normal; color: #1f8dd6; } -.autocomplete-suggestion.selected { background: #f0f0f0; } + text-align: left; + cursor: default; + border: 1px solid #ccc; + border-top: 0; + background: #fff; + box-shadow: -1px 1px 3px rgba(0, 0, 0, .1); + /* core styles should not be changed */ + position: absolute; + display: none; + z-index: 9999; + max-height: 254px; + overflow: hidden; + overflow-y: auto; + box-sizing: border-box; + } + .autocomplete-suggestion { + position: relative; + padding: 0 .6em; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + color: #333; + /* for below styles, match semantic presentation */ + font-size: 1em; + line-height: 1; + padding-top: 0.78571429rem; + padding-bottom: 0.78571429rem; + } + .autocomplete-suggestion b { + font-weight: normal; + color: #1f8dd6; + } + .autocomplete-suggestion.selected { + background: #f0f0f0; + } \ No newline at end of file diff --git a/bl-kernel/admin/themes/booty/js/jquery-auto-complete.min.js b/bl-kernel/admin/themes/booty/js/jquery-auto-complete.min.js index c6deb2f2..4e362c97 100755 --- a/bl-kernel/admin/themes/booty/js/jquery-auto-complete.min.js +++ b/bl-kernel/admin/themes/booty/js/jquery-auto-complete.min.js @@ -1,3 +1,7 @@ -// jQuery autoComplete v1.0.7 -// https://github.com/Pixabay/jQuery-autoComplete -!function(e){e.fn.autoComplete=function(t){var o=e.extend({},e.fn.autoComplete.defaults,t);return"string"==typeof t?(this.each(function(){var o=e(this);"destroy"==t&&(e(window).off("resize.autocomplete",o.updateSC),o.off("blur.autocomplete focus.autocomplete keydown.autocomplete keyup.autocomplete"),o.data("autocomplete")?o.attr("autocomplete",o.data("autocomplete")):o.removeAttr("autocomplete"),e(o.data("sc")).remove(),o.removeData("sc").removeData("autocomplete"))}),this):this.each(function(){function t(e){var t=s.val();if(s.cache[t]=e,e.length&&t.length>=o.minChars){for(var a="",c=0;c'),s.data("sc",s.sc).data("autocomplete",s.attr("autocomplete")),s.attr("autocomplete","off"),s.cache={},s.last_val="",s.updateSC=function(t,o){if(s.sc.css({top:s.offset().top+s.outerHeight(),left:s.offset().left,width:s.outerWidth()}),!t&&(s.sc.show(),s.sc.maxHeight||(s.sc.maxHeight=parseInt(s.sc.css("max-height"))),s.sc.suggestionHeight||(s.sc.suggestionHeight=e(".autocomplete-suggestion",s.sc).first().outerHeight()),s.sc.suggestionHeight))if(o){var a=s.sc.scrollTop(),c=o.offset().top-s.sc.offset().top;c+s.sc.suggestionHeight-s.sc.maxHeight>0?s.sc.scrollTop(c+s.sc.suggestionHeight+a-s.sc.maxHeight):0>c&&s.sc.scrollTop(c+a)}else s.sc.scrollTop(0)},e(window).on("resize.autocomplete",s.updateSC),s.sc.appendTo("body"),s.sc.on("mouseleave",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected")}),s.sc.on("mouseenter",".autocomplete-suggestion",function(){e(".autocomplete-suggestion.selected").removeClass("selected"),e(this).addClass("selected")}),s.sc.on("mousedown click",".autocomplete-suggestion",function(t){var a=e(this),c=a.data("val");return(c||a.hasClass("autocomplete-suggestion"))&&(s.val(c),o.onSelect(t,c,a),s.sc.hide()),!1}),s.on("blur.autocomplete",function(){try{over_sb=e(".autocomplete-suggestions:hover").length}catch(t){over_sb=0}over_sb?s.is(":focus")||setTimeout(function(){s.focus()},20):(s.last_val=s.val(),s.sc.hide(),setTimeout(function(){s.sc.hide()},350))}),o.minChars||s.on("focus.autocomplete",function(){s.last_val="\n",s.trigger("keyup.autocomplete")}),s.on("keydown.autocomplete",function(t){if((40==t.which||38==t.which)&&s.sc.html()){var a,c=e(".autocomplete-suggestion.selected",s.sc);return c.length?(a=40==t.which?c.next(".autocomplete-suggestion"):c.prev(".autocomplete-suggestion"),a.length?(c.removeClass("selected"),s.val(a.addClass("selected").data("val"))):(c.removeClass("selected"),s.val(s.last_val),a=0)):(a=40==t.which?e(".autocomplete-suggestion",s.sc).first():e(".autocomplete-suggestion",s.sc).last(),s.val(a.addClass("selected").data("val"))),s.updateSC(0,a),!1}if(27==t.which)s.val(s.last_val).sc.hide();else if(13==t.which||9==t.which){var c=e(".autocomplete-suggestion.selected",s.sc);c.length&&s.sc.is(":visible")&&(o.onSelect(t,c.data("val"),c),setTimeout(function(){s.sc.hide()},20))}}),s.on("keyup.autocomplete",function(a){if(!~e.inArray(a.which,[13,27,35,36,37,38,39,40])){var c=s.val();if(c.length>=o.minChars){if(c!=s.last_val){if(s.last_val=c,clearTimeout(s.timer),o.cache){if(c in s.cache)return void t(s.cache[c]);for(var l=1;l'+e.replace(o,"$1")+""},onSelect:function(e,t,o){}}}(jQuery); +/* + jQuery autoComplete v1.0.7-tizra.5 + Copyright (c) 2014 Simon Steinberger / Pixabay + License: http://www.opensource.org/licenses/mit-license.php + @preserve (for uglifyjs) +*/ +(function($){$.fn.autoComplete=function(options){var o=$.extend({},$.fn.autoComplete.defaults,options);if(typeof options=="string"){this.each(function(){var that=$(this);if(options=="destroy"){$(window).off("resize.autocomplete",that.updateSC);that.off("blur.autocomplete focus.autocomplete keydown.autocomplete keyup.autocomplete");if(that.data("autocomplete"))that.attr("autocomplete",that.data("autocomplete"));else that.removeAttr("autocomplete");$(that.data("sc")).remove();that.removeData("sc").removeData("autocomplete")}});return this}return this.each(function(){var that=$(this);that.sc=$('
');that.data("sc",that.sc).data("autocomplete",that.attr("autocomplete"));that.attr("autocomplete","off");that.cache={};that.last_val="";that.submitting=false;that.updateSC=function(resize,next){that.sc.css({top:that.offset().top+that.outerHeight(),left:that.offset().left,width:that.outerWidth()});if(!resize){that.sc.show();if(!that.sc.maxHeight)that.sc.maxHeight=parseInt(that.sc.css("max-height"));if(!that.sc.suggestionHeight)that.sc.suggestionHeight=$(".autocomplete-suggestion",that.sc).first().outerHeight();if(that.sc.suggestionHeight)if(!next)that.sc.scrollTop(0);else{var scrTop=that.sc.scrollTop(),selTop=next.offset().top-that.sc.offset().top;if(selTop+that.sc.suggestionHeight-that.sc.maxHeight>0)that.sc.scrollTop(selTop+that.sc.suggestionHeight+scrTop-that.sc.maxHeight);else if(selTop<0)that.sc.scrollTop(selTop+scrTop)}}};$(window).on("resize.autocomplete",that.updateSC);that.sc.appendTo("body");that.sc.on("mouseleave",".autocomplete-suggestion",function(){$(".autocomplete-suggestion.selected").removeClass("selected")});that.sc.on("mouseenter",".autocomplete-suggestion",function(){$(".autocomplete-suggestion.selected").removeClass("selected");$(this).addClass("selected")});that.sc.on("mousedown click",".autocomplete-suggestion",function(e){var item=$(this),v=item.attr("data-val");if(v||item.hasClass("autocomplete-suggestion")){that.val(v);o.onSelect(e,v,item);that.sc.hide()}return false});that.on("blur.autocomplete",function(){try{over_sb=$(".autocomplete-suggestions:hover").length}catch(e){over_sb=0}if(!over_sb){that.last_val=that.val();that.sc.hide();setTimeout(function(){that.sc.hide()},350)}else if(!that.is(":focus"))setTimeout(function(){that.focus()},20)});if(!o.minChars)that.on("focus.autocomplete",function(){that.last_val="\n";that.trigger("keyup.autocomplete")});function suggest(data,val){that.cache[val]=data;if(!data.length){that.sc.hide()}else if(val===that.val()&&that.is(":focus")&&!that.submitting){var s="";for(var i=0;i=o.minChars){if(val!=that.last_val){that.last_val=val;clearTimeout(that.timer);if(o.cache){if(val in that.cache){suggest(that.cache[val],val);return}for(var i=1;i'+item.replace(re,"$1")+""},onSelect:function(e,term,item){}}})(jQuery); \ No newline at end of file diff --git a/bl-kernel/admin/views/edit-content.php b/bl-kernel/admin/views/edit-content.php index 0f9419b1..cd0a6b26 100644 --- a/bl-kernel/admin/views/edit-content.php +++ b/bl-kernel/admin/views/edit-content.php @@ -280,7 +280,7 @@ echo Bootstrap::formOpen(array( }, onSelect: function(event, term, item) { // parentsList = array( pageTitle => pageKey ) - var parentKey = parentsList[term]; + var parentKey = parentsList[sanitizeHTML(term)]; $("#jsparent").attr("value", parentKey); } }); diff --git a/bl-kernel/admin/views/new-content.php b/bl-kernel/admin/views/new-content.php index 9b3568dd..fd1aa61a 100644 --- a/bl-kernel/admin/views/new-content.php +++ b/bl-kernel/admin/views/new-content.php @@ -256,7 +256,7 @@ echo Bootstrap::formOpen(array( }, onSelect: function(event, term, item) { // parentsList = array( pageTitle => pageKey ) - var parentKey = parentsList[term]; + var parentKey = parentsList[sanitizeHTML(term)]; $("#jsparent").attr("value", parentKey); } });