Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
ad6c97ec
Commit
ad6c97ec
authored
Jun 13, 2018
by
Openset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update: Htmlquote Htmlunquote
parent
d3d97de3
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
19 deletions
+8
-19
templatefunc.go
templatefunc.go
+8
-19
No files found.
templatefunc.go
View file @
ad6c97ec
...
@@ -17,6 +17,7 @@ package beego
...
@@ -17,6 +17,7 @@ package beego
import
(
import
(
"errors"
"errors"
"fmt"
"fmt"
"html"
"html/template"
"html/template"
"net/url"
"net/url"
"reflect"
"reflect"
...
@@ -207,14 +208,12 @@ func Htmlquote(text string) string {
...
@@ -207,14 +208,12 @@ func Htmlquote(text string) string {
'<'&">'
'<'&">'
*/
*/
text
=
strings
.
Replace
(
text
,
"&"
,
"&"
,
-
1
)
// Must be done first!
text
=
html
.
EscapeString
(
text
)
text
=
strings
.
Replace
(
text
,
"<"
,
"<"
,
-
1
)
text
=
strings
.
NewReplacer
(
text
=
strings
.
Replace
(
text
,
">"
,
">"
,
-
1
)
`“`
,
"“"
,
text
=
strings
.
Replace
(
text
,
"'"
,
"'"
,
-
1
)
`”`
,
"”"
,
text
=
strings
.
Replace
(
text
,
"
\"
"
,
"""
,
-
1
)
` `
,
" "
,
text
=
strings
.
Replace
(
text
,
"“"
,
"“"
,
-
1
)
)
.
Replace
(
text
)
text
=
strings
.
Replace
(
text
,
"”"
,
"”"
,
-
1
)
text
=
strings
.
Replace
(
text
,
" "
,
" "
,
-
1
)
return
strings
.
TrimSpace
(
text
)
return
strings
.
TrimSpace
(
text
)
}
}
...
@@ -228,17 +227,7 @@ func Htmlunquote(text string) string {
...
@@ -228,17 +227,7 @@ func Htmlunquote(text string) string {
'<\\'&">'
'<\\'&">'
*/
*/
// strings.Replace(s, old, new, n)
text
=
html
.
UnescapeString
(
text
)
// 在s字符串中,把old字符串替换为new字符串,n表示替换的次数,小于0表示全部替换
text
=
strings
.
Replace
(
text
,
" "
,
" "
,
-
1
)
text
=
strings
.
Replace
(
text
,
"”"
,
"”"
,
-
1
)
text
=
strings
.
Replace
(
text
,
"“"
,
"“"
,
-
1
)
text
=
strings
.
Replace
(
text
,
"""
,
"
\"
"
,
-
1
)
text
=
strings
.
Replace
(
text
,
"'"
,
"'"
,
-
1
)
text
=
strings
.
Replace
(
text
,
">"
,
">"
,
-
1
)
text
=
strings
.
Replace
(
text
,
"<"
,
"<"
,
-
1
)
text
=
strings
.
Replace
(
text
,
"&"
,
"&"
,
-
1
)
// Must be done last!
return
strings
.
TrimSpace
(
text
)
return
strings
.
TrimSpace
(
text
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment