From 0f7ebb6c5324f389d464a3468169ad1bbc8f2c7e Mon Sep 17 00:00:00 2001 From: Refactoring Date: Fri, 27 Mar 2015 14:56:37 +0800 Subject: [PATCH] fix bug: Email validation missing contains "-" example: name1-name2@site.com, name@site1-site2.com --- app/lea/Util.go | 39 ++++++++++++++++++++------------------- public/js/common-min.js | 2 +- public/js/common.js | 2 +- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/app/lea/Util.go b/app/lea/Util.go index 3d28047..7ddcc1d 100644 --- a/app/lea/Util.go +++ b/app/lea/Util.go @@ -1,16 +1,16 @@ package lea import ( - "fmt" - "regexp" "crypto/md5" "crypto/rand" "encoding/base64" "encoding/hex" - "io" + "fmt" "gopkg.in/mgo.v2/bson" + "io" + math_rand "math/rand" + "regexp" "time" - math_rand "math/rand" ) // 字符串 @@ -58,7 +58,7 @@ func Substr(str string, start, length int) string { func substr(str string, start, length int, isRune bool) string { rs := []rune(str) rs2 := []byte(str) - + rl := len(rs) if !isRune { rl = len(rs2) @@ -124,12 +124,12 @@ func ReplaceAll(oldStr, pattern, newStr string) string { func SubStringHTML(param string, length int, end string) string { // 先取出
占位..
-	
+
 	result := ""
 
 	// 1
 	n := 0
-	var temp rune // 中文问题, 用rune来解决
+	var temp rune   // 中文问题, 用rune来解决
 	isCode := false //是不是HTML代码
 	isHTML := false //是不是HTML特殊字符,如 
 	rStr := []rune(param)
@@ -154,7 +154,7 @@ func SubStringHTML(param string, length int, end string) string {
 		}
 	}
 	result += end
-	
+
 	// 取出所有标签
 	tempResult := ReplaceAll(result, "(>)[^<>]*(]*>", "<$1>")
-	
+
 	// 3 只能用正则,+stack来去有结束的
 	// golang的正则暂不支持back reference, 以后可以用它来去掉重复的标签
 	p, _ := regexp.Compile("<(/?[a-zA-Z]+)[^<>]*>") // 得到所有的
,
... strs := p.FindAllString(tempResult, -1) -// fmt.Println(strs) + // fmt.Println(strs) stack := make([]string, len(strs)) stackP := -1 for _, each := range strs { @@ -186,16 +186,17 @@ func SubStringHTML(param string, length int, end string) string { // 补全tag if stackP != -1 { fmt.Println(stack[0 : stackP+1]) - + for _, each := range stack[0 : stackP+1] { if each[1] != '/' { result += "FORTOKEN";var clearIntervalForSetContent;function setEditorContent(content,isMarkdown,preview){if(!content){content=""}if(clearIntervalForSetContent){clearInterval(clearIntervalForSetContent)}if(!isMarkdown){$("#editorContent").html(content);if(typeof tinymce!="undefined"&&tinymce.activeEditor){var editor=tinymce.activeEditor;editor.setContent(content);editor.undoManager.clear()}else{clearIntervalForSetContent=setTimeout(function(){setEditorContent(content,false)},100)}}else{if(MD){MD.setContent(content)}else{clearIntervalForSetContent=setTimeout(function(){setEditorContent(content,true)},100)}}}function previewIsEmpty(preview){if(!preview||preview.substr(0,previewToken.length)==previewToken){return true}return false}function getEditorContent(isMarkdown){if(!isMarkdown){var editor=tinymce.activeEditor;if(editor){var content=$(editor.getBody()).clone();content.find(".toggle-raw").remove();var pres=content.find("pre");for(var i=0;i/g,">");pre.removeAttr("style","").removeAttr("contenteditable").removeClass("ace_editor");pre.html(val)}}content.find("pinit").remove();content.find(".thunderpin").remove();content.find(".pin").parent().remove();content=$(content).html();if(content){while(true){var lastEndScriptPos=content.lastIndexOf("");if(lastEndScriptPos==-1){return content}var length=content.length;if(length-9==lastEndScriptPos){var lastScriptPos=content.lastIndexOf("");if(lastEndScriptPos==-1){return content}var length=content.length;if(length-9==lastEndScriptPos){var lastScriptPos=content.lastIndexOf("