diff --git a/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin.js b/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin.js index c29fbbbeb7b..8265f2a0fcb 100644 --- a/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin.js +++ b/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin.js @@ -1 +1 @@ -(function(){tinymce.create('tinymce.plugins.MoodleEmoticon',{_emoticons:{},init:function(ed,url){ed.addCommand('mceMoodleEmoticon',function(){lang=ed.getParam('language');ed.windowManager.open({file:url+'/dialog.php?lang='+lang,width:250+parseInt(ed.getLang('moodleemoticon.delta_width',0)),height:400+parseInt(ed.getLang('moodleemoticon.delta_height',0)),inline:1},{plugin_url:url,})});ed.onInit.add(function(ed){var data=ed.getContent();this._emoticons=tinymce.util.JSON.parse(ed.getParam('moodleemoticon_emoticons'));for(var emotxt in this._emoticons){data=data.replace(emotxt,this._emoticons[emotxt])}ed.setContent(data)});ed.onPreProcess.add(function(ed,o){if(o.save){tinymce.each(ed.dom.select('img.emoticon',o.node),function(image){var emoticontxt='';var matches=/^emoticon emoticon-index-([0-9]+)$/.exec(image.className);if(matches.length!=2){return true}var index=matches[1];var search=new RegExp('class="emoticon emoticon-index-'.concat(index,'"'));for(var emotxt in this._emoticons){if(search.test(this._emoticons[emotxt])){emoticontxt=emotxt;break}}if(emoticontxt){ed.dom.setOuterHTML(image,emoticontxt)}},this)}});ed.addButton('moodleemoticon',{title:'moodleemoticon.desc',cmd:'mceMoodleEmoticon',image:url+'/img/moodleemoticon.gif'})},createControl:function(n,cm){return null},getInfo:function(){return{longname:'Moodle Emoticon plugin',author:'David Mudrak',authorurl:'http://mudrak.name',infourl:'http://moodle.org',version:"1.0"}}});tinymce.PluginManager.add('moodleemoticon',tinymce.plugins.MoodleEmoticon)})(); +(function(){tinymce.create('tinymce.plugins.MoodleEmoticon',{_emoticons:{},init:function(ed,url){ed.addCommand('mceMoodleEmoticon',function(){lang=ed.getParam('language');ed.windowManager.open({file:url+'/dialog.php?lang='+lang,width:250+parseInt(ed.getLang('moodleemoticon.delta_width',0)),height:400+parseInt(ed.getLang('moodleemoticon.delta_height',0)),inline:1},{plugin_url:url,})});ed.onInit.add(function(ed){var data=ed.getContent();this._emoticons=tinymce.util.JSON.parse(ed.getParam('moodleemoticon_emoticons'));for(var emotxt in this._emoticons){search=emotxt.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,'\\$&');search=new RegExp(search,'g');data=data.replace(search,this._emoticons[emotxt])}ed.setContent(data)});ed.onPreProcess.add(function(ed,o){if(o.save){tinymce.each(ed.dom.select('img.emoticon',o.node),function(image){var emoticontxt='';var matches=/^emoticon emoticon-index-([0-9]+)$/.exec(image.className);if(matches.length!=2){return true}var index=matches[1];var search=new RegExp('class="emoticon emoticon-index-'.concat(index,'"'));for(var emotxt in this._emoticons){if(search.test(this._emoticons[emotxt])){emoticontxt=emotxt;break}}if(emoticontxt){ed.dom.setOuterHTML(image,emoticontxt)}},this)}});ed.addButton('moodleemoticon',{title:'moodleemoticon.desc',cmd:'mceMoodleEmoticon',image:url+'/img/moodleemoticon.gif'})},createControl:function(n,cm){return null},getInfo:function(){return{longname:'Moodle Emoticon plugin',author:'David Mudrak',authorurl:'http://mudrak.name',infourl:'http://moodle.org',version:"1.0"}}});tinymce.PluginManager.add('moodleemoticon',tinymce.plugins.MoodleEmoticon)})(); diff --git a/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin_src.js b/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin_src.js index c1f7954a6bd..51e3022948a 100644 --- a/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin_src.js +++ b/lib/editor/tinymce/tiny_mce/3.3.9.2/plugins/moodleemoticon/editor_plugin_src.js @@ -44,7 +44,12 @@ var data = ed.getContent(); this._emoticons = tinymce.util.JSON.parse(ed.getParam('moodleemoticon_emoticons')); for (var emotxt in this._emoticons) { - data = data.replace(emotxt, this._emoticons[emotxt]); + // escape the metacharacters so we can use it as regexp + search = emotxt.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); + // convert to regexp + search = new RegExp(search, 'g'); + // and replace all occurrences of it with the image + data = data.replace(search, this._emoticons[emotxt]); } ed.setContent(data); });