-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
207 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,4 +38,6 @@ yarn.lock | |
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
|
||
tmp | ||
tmp | ||
exportfile | ||
userUpload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ export class Session extends BaseEntity { | |
|
||
@Column() | ||
surveyId: string; | ||
|
||
@Column() | ||
userId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,53 @@ | ||
import xss from 'xss' | ||
import xss from 'xss'; | ||
|
||
const myxss = new (xss as any).FilterXSS({ | ||
onIgnoreTagAttr(tag, name, value) { | ||
if (name === 'style' || name === 'class') { | ||
return `${name}="${value}"` | ||
return `${name}="${value}"`; | ||
} | ||
return undefined | ||
return undefined; | ||
}, | ||
onIgnoreTag(tag, html) { | ||
// <xxx>过滤为空,否则不过滤为空 | ||
var re1 = new RegExp('<.+?>', 'g') | ||
const re1 = new RegExp('<.+?>', 'g'); | ||
if (re1.test(html)) { | ||
return '' | ||
return ''; | ||
} else { | ||
return html | ||
return html; | ||
} | ||
} | ||
}) | ||
}, | ||
}); | ||
|
||
export const cleanRichTextWithMediaTag = (text) => { | ||
if (!text) { | ||
return text === 0 ? 0 : '' | ||
return text === 0 ? 0 : ''; | ||
} | ||
const html = transformHtmlTag(text) | ||
.replace(/<img([\w\W]+?)\/>/g, '[图片]') | ||
.replace(/<video.*\/video>/g, '[视频]') | ||
const content = html.replace(/<[^<>]+>/g, '').replace(/ /g, '') | ||
.replace(/<video.*\/video>/g, '[视频]'); | ||
const content = html.replace(/<[^<>]+>/g, '').replace(/ /g, ''); | ||
|
||
return content | ||
} | ||
return content; | ||
}; | ||
|
||
export function escapeHtml(html) { | ||
return html.replace(/</g, '<').replace(/>/g, '>') | ||
return html.replace(/</g, '<').replace(/>/g, '>'); | ||
} | ||
export const transformHtmlTag = (html) => { | ||
if (!html) return '' | ||
if (typeof html !== 'string') return html + '' | ||
if (!html) return ''; | ||
if (typeof html !== 'string') return html + ''; | ||
return html | ||
.replace(html ? /&(?!#?\w+;)/g : /&/g, '&') | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/"/g, '"') | ||
.replace(/'/g, "'") | ||
.replace(/\\\n/g, '\\n') | ||
.replace(/\\\n/g, '\\n'); | ||
//.replace(/ /g, "") | ||
} | ||
}; | ||
|
||
const filterXSSClone = myxss.process.bind(myxss) | ||
const filterXSSClone = myxss.process.bind(myxss); | ||
|
||
export const filterXSS = (html) => filterXSSClone(transformHtmlTag(html)) | ||
export const filterXSS = (html) => filterXSSClone(transformHtmlTag(html)); | ||
|
||
export const escapeFilterXSS = (html) => escapeHtml(filterXSS(html)) | ||
export const escapeFilterXSS = (html) => escapeHtml(filterXSS(html)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.