From 75a5398930199447e72e6011ba2683316b388aa4 Mon Sep 17 00:00:00 2001 From: devjin Date: Wed, 8 Aug 2012 13:20:08 +0000 Subject: [PATCH] issue 2010 modified the regular expression of email. (add + . ~) git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.3.2@11004 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- classes/validator/Validator.class.php | 2 +- .../xml/xmlquery/argument/Argument.class.php | 2 +- common/js/xe.js | 2 +- common/js/xe.min.js | 257 +++++------------- common/js/xml_js_filter.js | 2 +- 5 files changed, 74 insertions(+), 191 deletions(-) diff --git a/classes/validator/Validator.class.php b/classes/validator/Validator.class.php index 5f4c47e3e..83b373590 100644 --- a/classes/validator/Validator.class.php +++ b/classes/validator/Validator.class.php @@ -71,7 +71,7 @@ class Validator // predefined rules $this->addRule(array( - 'email' => '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/', + 'email' => '/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/', 'userid' => '/^[a-z]+[\w-]*[a-z0-9_]+$/i', 'url' => '/^(https?|ftp|mms):\/\/[0-9a-z-]+(\.[_0-9a-z-]+)+(:\d+)?/', 'alpha' => '/^[a-z]*$/i', diff --git a/classes/xml/xmlquery/argument/Argument.class.php b/classes/xml/xmlquery/argument/Argument.class.php index 7136f7d22..5ac884869 100644 --- a/classes/xml/xmlquery/argument/Argument.class.php +++ b/classes/xml/xmlquery/argument/Argument.class.php @@ -204,7 +204,7 @@ class Argument { switch ($filter_type) { case 'email' : case 'email_address' : - if (!preg_match('/^[_0-9a-z-]+(\.[_0-9a-z-]+)*@[0-9a-z-]+(\.[0-9a-z-]+)*$/is', $val)) { + if (!preg_match('/^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/is', $val)) { $this->isValid = false; $this->errorMessage = new Object(-1, sprintf($lang->filter->invalid_email, $lang->{$key} ? $lang->{$key} : $key)); } diff --git a/common/js/xe.js b/common/js/xe.js index 42c052a13..516c5757e 100644 --- a/common/js/xe.js +++ b/common/js/xe.js @@ -1706,7 +1706,7 @@ var Validator = xe.createApp('Validator', { init : function() { // {{{ add filters // email - var regEmail = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; + var regEmail = /^[\w-]+((?:\.|\+|\~)[\w-]+)*@[\w-]+(\.[\w-]+)+$/; this.cast('ADD_RULE', ['email', regEmail]); this.cast('ADD_RULE', ['email_address', regEmail]); diff --git a/common/js/xe.min.js b/common/js/xe.min.js index 4284538e3..68b8088f7 100644 --- a/common/js/xe.min.js +++ b/common/js/xe.min.js @@ -3,190 +3,73 @@ * @author NHN (developers@xpressengine.com) * @brief XE Common JavaScript **/ -(function($){var _xe_base,_app_base,_plugin_base;var _apps=[];_xe_base={getName:function(){return'Core';},createApp:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_app_base,oDef);_base.prototype.getName=function(){return sName;};return _base;},createPlugin:function(sName,oDef){var _base=getTypeBase();$.extend(_base.prototype,_plugin_base,oDef);_base.prototype.getName=function(){return sName;};return _base;},getApps:function(){return $.makeArray(_apps);},getApp:function(indexOrName){indexOrName=(indexOrName||'').toLowerCase();if(typeof _apps[indexOrName]!='undefined'){return _apps[indexOrName];}else{return null;}},registerApp:function(oApp){var sName=oApp.getName().toLowerCase();_apps.push(oApp);if(!$.isArray(_apps[sName])){_apps[sName]=[];} -_apps[sName].push(oApp);oApp.parent=this;if($.isFunction(oApp.activate))oApp.activate();},unregisterApp:function(oApp){var sName=oApp.getName().toLowerCase();var nIndex=$.inArray(oApp,_apps);if(nIndex>=0)_apps=_apps.splice(nIndex,1);if($.isArray(_apps[sName])){nIndex=$.inArray(oApp,_apps[sName]);if(nIndex>=0)_apps[sName]=_apps[sName].splice(nIndex,1);} -if($.isFunction(oApp.deactivate))oApp.deactivate();},broadcast:function(msg,params){this._broadcast(this,msg,params);},_broadcast:function(sender,msg,params){for(var i=0;i<_apps.length;i++){_apps[i]._cast(sender,msg,params);} -this._cast(sender,msg,params);}} -_app_base={_plugins:[],_messages:{},getPlugin:function(sPluginName){sPluginName=sPluginName.toLowerCase();if($.isArray(this._plugins[sPluginName])){return this._plugins[sPluginName];}else{return[];}},registerPlugin:function(oPlugin){var self=this;var sName=oPlugin.getName().toLowerCase();if($.inArray(oPlugin,this._plugins)>=0)return false;this._plugins.push(oPlugin);if(!$.isArray(this._plugins[sName]))this._plugins[sName]=[];this._plugins[sName].push(oPlugin);$.each(oPlugin._binded_fn,function(api,fn){self.registerHandler(api,fn);});oPlugin.oApp=this;if($.isFunction(oPlugin.activate))oPlugin.activate();return true;},registerHandler:function(api,func){var msgs=this._messages;api=api.toUpperCase();if(!$.isArray(msgs[api]))msgs[api]=[];msgs[api].push(func);},cast:function(msg,params){return this._cast(this,msg,params||[]);},broadcast:function(sender,msg,params){if(this.parent&&this.parent._broadcast){this.parent._broadcast(sender,msg,params);}},_cast:function(sender,msg,params){var i,len;var aMsg=this._messages;msg=msg.toUpperCase();if(aMsg['BEFORE_'+msg]||this['API_BEFORE_'+msg]){var bContinue=this._cast(sender,'BEFORE_'+msg,params);if(!bContinue)return;} -var vRet=[],sFn='API_'+msg;if($.isArray(aMsg[msg])){for(i=0;i'+str+' ';}}} -this.loaded_popup_menus[menu_id]=html;} -if(html){var area=$('#popup_menu_area').html('');var areaOffset={top:params['page_y'],left:params['page_x']};if(area.outerHeight()+areaOffset.top>$(window).height()+$(window).scrollTop()) -areaOffset.top=$(window).height()-area.outerHeight()+$(window).scrollTop();if(area.outerWidth()+areaOffset.left>$(window).width()+$(window).scrollLeft()) -areaOffset.left=$(window).width()-area.outerWidth()+$(window).scrollLeft();area.css({top:areaOffset.top,left:areaOffset.left}).show();}}}})(jQuery);jQuery(function($){if($.browser.msie){$('select').each(function(i,sels){var disabled_exists=false;var first_enable=new Array();for(var j=0;j-1)?first_enable[i]:j;}} -if(!disabled_exists)return;sels.oldonchange=sels.onchange;sels.onchange=function(){if(this.options[this.selectedIndex].disabled){this.selectedIndex=first_enable[i];}else{if(this.oldonchange)this.oldonchange();}};if(sels.selectedIndex>=0&&sels.options[sels.selectedIndex].disabled)sels.onchange();});} -var drEditorFold=$('.xe_content .fold_button');if(drEditorFold.size()){var fold_container=$('div.fold_container',drEditorFold);$('button.more',drEditorFold).click(function(){$(this).hide().next('button').show().parent().next(fold_container).show();});$('button.less',drEditorFold).click(function(){$(this).hide().prev('button').show().parent().next(fold_container).hide();});}});(function(){function isSameUrl(a,b){return(a.replace(/#.*$/,'')===b.replace(/#.*$/,''));} -var isArray=Array.isArray||function(obj){return Object.prototype.toString.call(obj)=='[object Array]'};String.prototype.getQuery=function(key){var loc=isSameUrl(this,window.location.href)?current_url:this;var idx=loc.indexOf('?');if(idx==-1)return null;var query_string=loc.substr(idx+1,this.length),args={};query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(){args[arguments[1]]=arguments[2];});var q=args[key];if(typeof(q)=='undefined')q='';return q;} -String.prototype.setQuery=function(key,val){var loc=isSameUrl(this,window.location.href)?current_url:this;var idx=loc.indexOf('?');var uri=loc.replace(/#$/,'');var act,re,v;if(typeof(val)=='undefined')val='';if(idx!=-1){var query_string=uri.substr(idx+1,loc.length),args={},q_list=[];uri=loc.substr(0,idx);query_string.replace(/([^=]+)=([^&]*)(&|$)/g,function(all,key,val){args[key]=val;});args[key]=val;for(var prop in args){if(!args.hasOwnProperty(prop))continue;if(!(v=String(args[prop]).trim()))continue;q_list.push(prop+'='+decodeURI(v));} -query_string=q_list.join('&');uri=uri+(query_string?'?'+query_string:'');}else{if(String(val).trim())uri=uri+'?'+key+'='+val;} -re=/^https:\/\/([^:\/]+)(:\d+|)/i;if(re.test(uri)){var toReplace='http://'+RegExp.$1;if(window.http_port&&http_port!=80)toReplace+=':'+http_port;uri=uri.replace(re,toReplace);} -var bUseSSL=!!window.enforce_ssl;if(!bUseSSL&&isArray(window.ssl_actions)&&(act=uri.getQuery('act'))){for(var i=0,c=ssl_actions.length;i-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);try{if(target!="_blank"&&winopen_list[target]){winopen_list[target].close();winopen_list[target]=null;}}catch(e){} -if(typeof(target)=='undefined')target='_blank';if(typeof(attribute)=='undefined')attribute='';var win=window.open(url,target,attribute);win.focus();if(target!="_blank")winopen_list[target]=win;} -function popopen(url,target){if(typeof(target)=="undefined")target="_blank";if(typeof(xeVid)!='undefined'&&url.indexOf(request_uri)>-1&&!url.getQuery('vid'))url=url.setQuery('vid',xeVid);winopen(url,target,"width=650,height=500,scrollbars=yes,resizable=yes,toolbars=no");} -function sendMailTo(to){location.href="mailto:"+to;} -function move_url(url,open_wnidow){if(!url)return false;if(typeof(open_wnidow)=='undefined')open_wnidow='N';if(open_wnidow=='N'){open_wnidow=false;}else{open_wnidow=true;} -if(/^\./.test(url))url=request_uri+url;if(open_wnidow){winopen(url);}else{location.href=url;} -return false;} -function displayMultimedia(src,width,height,options){var html=_displayMultimedia(src,width,height,options);if(html)document.writeln(html);} -function _displayMultimedia(src,width,height,options){if(src.indexOf('files')==0)src=request_uri+src;var defaults={wmode:'transparent',allowScriptAccess:'sameDomain',quality:'high',flashvars:'',autostart:false};var params=jQuery.extend(defaults,options||{});var autostart=(params.autostart&¶ms.autostart!='false')?'true':'false';delete(params.autostart);var clsid="";var codebase="";var html="";if(/\.(gif|jpg|jpeg|bmp|png)$/i.test(src)){html='';}else if(/\.flv$/i.test(src)||/\.mov$/i.test(src)||/\.moov$/i.test(src)||/\.m4v$/i.test(src)){html='';}else if(/\.swf/i.test(src)){clsid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';if(typeof(enforce_ssl)!='undefined'&&enforce_ssl){codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";} -else{codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0";} -html='';html+='';for(var name in params){if(params[name]!='undefined'&¶ms[name]!=''){html+='';}} -html+='' -+'' -+'';}else{if(jQuery.browser.mozilla||jQuery.browser.opera){autostart=(params.autostart&¶ms.autostart!='false')?'1':'0';} -html='.popup'),w,h,dw,dh,offset;offset=$pc.css({overflow:'scroll'}).offset();w=$pc.width(10).height(10000).get(0).scrollWidth+offset.left*2;h=$pc.height(10).width(10000).get(0).scrollHeight+offset.top*2;if(w<600)w=600+offset.left*2;dw=$win.width();dh=$win.height();if(w!=dw)window.resizeBy(w-dw,0);if(h!=dh)window.resizeBy(0,h-dh);$pc.width(w-offset.left*2).css({overflow:'',height:''});} -function doCallModuleAction(module,action,target_srl){var params={target_srl:target_srl,cur_mid:current_mid,mid:current_mid};exec_xml(module,action,params,completeCallModuleAction);} -function completeCallModuleAction(ret_obj,response_tags){if(ret_obj['message']!='success')alert(ret_obj['message']);location.reload();} -function completeMessage(ret_obj){alert(ret_obj['message']);location.reload();} -function doChangeLangType(obj){if(typeof(obj)=="string"){setLangType(obj);}else{var val=obj.options[obj.selectedIndex].value;setLangType(val);} -location.href=location.href.setQuery('l','');} -function setLangType(lang_type){var expire=new Date();expire.setTime(expire.getTime()+(7000*24*3600000));setCookie('lang_type',lang_type,expire,'/');} -function doDocumentPreview(obj){var fo_obj=obj;while(fo_obj.nodeName!="FORM"){fo_obj=fo_obj.parentNode;} -if(fo_obj.nodeName!="FORM")return;var editor_sequence=fo_obj.getAttribute('editor_sequence');var content=editorGetContent(editor_sequence);var win=window.open("","previewDocument","toolbars=no,width=700px;height=800px,scrollbars=yes,resizable=yes");var dummy_obj=jQuery("#previewDocument");if(!dummy_obj.length){jQuery('
'+''+''+''+'
').appendTo(document.body);dummy_obj=jQuery("#previewDocument")[0];}else{dummy_obj=dummy_obj[0];} -if(dummy_obj){dummy_obj.content.value=content;dummy_obj.submit();}} -function doDocumentSave(obj){var editor_sequence=obj.form.getAttribute('editor_sequence');var prev_content=editorRelKeys[editor_sequence]['content'].value;if(typeof(editor_sequence)!='undefined'&&editor_sequence&&typeof(editorRelKeys)!='undefined'&&typeof(editorGetContent)=='function'){var content=editorGetContent(editor_sequence);editorRelKeys[editor_sequence]['content'].value=content;} -var params={},responses=['error','message','document_srl'],elms=obj.form.elements,data=jQuery(obj.form).serializeArray();;jQuery.each(data,function(i,field){var val=jQuery.trim(field.value);if(!val)return true;if(/\[\]$/.test(field.name))field.name=field.name.replace(/\[\]$/,'');if(params[field.name])params[field.name]+='|@|'+val;else params[field.name]=field.value;});exec_xml('document','procDocumentTempSave',params,completeDocumentSave,responses,params,obj.form);editorRelKeys[editor_sequence]['content'].value=prev_content;return false;} -function completeDocumentSave(ret_obj){jQuery('input[name=document_srl]').eq(0).val(ret_obj['document_srl']);alert(ret_obj['message']);} -var objForSavedDoc=null;function doDocumentLoad(obj){objForSavedDoc=obj.form;popopen(request_uri.setQuery('module','document').setQuery('act','dispTempSavedList'));} -function doDocumentSelect(document_srl){if(!opener||!opener.objForSavedDoc){window.close();return;} -opener.location.href=opener.current_url.setQuery('document_srl',document_srl).setQuery('act','dispBoardWrite');window.close();} -function viewSkinInfo(module,skin){popopen("./?module=module&act=dispModuleSkinInfo&selected_module="+module+"&skin="+skin,'SkinInfo');} -var addedDocument=new Array();function doAddDocumentCart(obj){var srl=obj.value;addedDocument[addedDocument.length]=srl;setTimeout(function(){callAddDocumentCart(addedDocument.length);},100);} -function callAddDocumentCart(document_length){if(addedDocument.length<1||document_length!=addedDocument.length)return;var params=new Array();params["srls"]=addedDocument.join(",");exec_xml("document","procDocumentAddCart",params,null);addedDocument=new Array();} -function transRGB2Hex(value){if(!value)return value;if(value.indexOf('#')>-1)return value.replace(/^#/,'');if(value.toLowerCase().indexOf('rgb')<0)return value;value=value.replace(/^rgb\(/i,'').replace(/\)$/,'');value_list=value.split(',');var hex='';for(var i=0;i>2;enc2=((chr1&3)<<4)|(chr2>>4);enc3=((chr2&15)<<2)|(chr3>>6);enc4=chr3&63;if(isNaN(chr2)){enc3=enc4=64;}else if(isNaN(chr3)){enc4=64;} -output=output+ -this._keyStr.charAt(enc1)+this._keyStr.charAt(enc2)+ -this._keyStr.charAt(enc3)+this._keyStr.charAt(enc4);} -return output;},decode:function(input){var output="";var chr1,chr2,chr3;var enc1,enc2,enc3,enc4;var i=0;input=input.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(i>4);chr2=((enc2&15)<<4)|(enc3>>2);chr3=((enc3&3)<<6)|enc4;output=output+String.fromCharCode(chr1);if(enc3!=64){output=output+String.fromCharCode(chr2);} -if(enc4!=64){output=output+String.fromCharCode(chr3);}} -output=Base64._utf8_decode(output);return output;},_utf8_encode:function(string){string=string.replace(/\r\n/g,"\n");var utftext="";for(var n=0;n127)&&(c<2048)){utftext+=String.fromCharCode((c>>6)|192);utftext+=String.fromCharCode((c&63)|128);} -else{utftext+=String.fromCharCode((c>>12)|224);utftext+=String.fromCharCode(((c>>6)&63)|128);utftext+=String.fromCharCode((c&63)|128);}} -return utftext;},_utf8_decode:function(utftext){var string="";var i=0;var c=c1=c2=0;while(i191)&&(c<224)){c2=utftext.charCodeAt(i+1);string+=String.fromCharCode(((c&31)<<6)|(c2&63));i+=2;} -else{c2=utftext.charCodeAt(i+1);c3=utftext.charCodeAt(i+2);string+=String.fromCharCode(((c&15)<<12)|((c2&63)<<6)|(c3&63));i+=3;}} -return string;}} -if(typeof(resizeImageContents)=='undefined'){function resizeImageContents(){}} -if(typeof(activateOptionDisabled)=='undefined'){function activateOptionDisabled(){}} -objectExtend=jQuery.extend;function toggleDisplay(objId){jQuery('#'+objId).toggle();} -function checkboxSelectAll(formObj,name,checked){var itemName=name;var option={};if(typeof(formObj)!="undefined")option.wrap=formObj;if(typeof(checked)!="undefined")option.checked=checked;XE.checkboxToggleAll(itemName,option);} -function clickCheckBoxAll(formObj,name){var itemName=name;var option={doClick:true};if(typeof(formObj)!="undefined")option.wrap=formObj;XE.checkboxToggleAll(itemName,option);} -function svc_folder_open(id){jQuery("#_folder_open_"+id).hide();jQuery("#_folder_close_"+id).show();jQuery("#_folder_"+id).show();} -function svc_folder_close(id){jQuery("#_folder_open_"+id).show();jQuery("#_folder_close_"+id).hide();jQuery("#_folder_"+id).hide();} -function open_calendar(fo_id,day_str,callback_func){if(typeof(day_str)=="undefined")day_str="";var url="./common/tpl/calendar.php?";if(fo_id)url+="fo_id="+fo_id;if(day_str)url+="&day_str="+day_str;if(callback_func)url+="&callback_func="+callback_func;popopen(url,'Calendar');} -var loaded_popup_menus=XE.loaded_popup_menus;function createPopupMenu(){} -function chkPopupMenu(){} -function displayPopupMenu(ret_obj,response_tags,params){XE.displayPopupMenu(ret_obj,response_tags,params);} -function GetObjLeft(obj){return jQuery(obj).offset().left;} -function GetObjTop(obj){return jQuery(obj).offset().top;} -function replaceOuterHTML(obj,html){jQuery(obj).replaceWith(html);} -function getOuterHTML(obj){return jQuery(obj).html().trim();} -function setCookie(name,value,expire,path){var s_cookie=name+"="+escape(value)+ -((!expire)?"":("; expires="+expire.toGMTString()))+"; path="+((!path)?"/":path);document.cookie=s_cookie;} -function getCookie(name){var match=document.cookie.match(new RegExp(name+'=(.*?)(?:;|$)'));if(match)return unescape(match[1]);} -function is_def(v){return(typeof(v)!='undefined');} -function ucfirst(str){return str.charAt(0).toUpperCase()+str.slice(1);} -function get_by_id(id){return document.getElementById(id);} -jQuery(function($){$('.lang_code').each(function() -{var objText=$(this);var targetName=objText.attr("id");if(typeof(targetName)=="undefined")targetName=objText.attr("name");if(typeof(targetName)=="undefined")return;objText.after("find_langcode");});$(document).click(function(evt){var $area=$('#popup_menu_area');if(!$area.length)$area=$('