Skip to content
This repository has been archived by the owner on Nov 15, 2018. It is now read-only.

Commit

Permalink
fix: (issue #446) “动态”中的脚本转化为纯文本展示
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoe committed Jun 13, 2018
1 parent 4dabe4c commit a905620
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/FeedCard/FeedCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ export default {
},
methods: {
replaceURI(str) {
// 脚本内容以纯文本方式显示
const scriptRegex = /<\s*script\s*>(.*?)<\s*\/\s*script\s*>/i;
str = str.replace(scriptRegex, "&lt;script&gt;$1&lt;/script&gt;");
const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
return str
? str.replace(
Expand Down
5 changes: 4 additions & 1 deletion src/page/feed/feedDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,11 @@ export default {
},
methods: {
formatBody(str) {
const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
// 脚本内容以纯文本方式显示
const scriptRegex = /<\s*script\s*>(.*?)<\s*\/\s*script\s*>/i;
str = str.replace(scriptRegex, "&lt;script&gt;$1&lt;/script&gt;");
const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
return str
? str.replace(
reg,
Expand Down

0 comments on commit a905620

Please sign in to comment.