This repository has been archived by the owner on Apr 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* fix: LEAP-444: Implement HTML sanitization in LSF
- Loading branch information
1 parent
c0d9073
commit e24a306
Showing
9 changed files
with
57 additions
and
8 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
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { sanitizeHtml } from '../html'; | ||
|
||
const htmlSanitizeList = [ | ||
{ | ||
input: '<iframe src="http://malicious.com"></iframe>', | ||
expected: '', | ||
},{ | ||
input: '<script>alert(\'XSS\');</script>', | ||
expected: '', | ||
}, { | ||
input: '"><img src=x onerror=alert(\'XSS\')>', | ||
expected: '"><img src="x" />', | ||
},{ | ||
input: '<script>alert(1)</script foo=\'bar\'>', | ||
expected: '', | ||
},{ | ||
input: '><script>alert(\'XSS\')</script>', | ||
expected: '>', | ||
},{ | ||
input: '<?xml version="1.0" encoding="ISO-8859-1"?><foo><![CDATA[<script>alert(\'XSS\');</script>]]></foo>', | ||
expected: '<foo></foo>', | ||
},{ | ||
input: 'It\'s a test to check if <, > and & are escaped', | ||
expected: 'It\'s a test to check if <, > and & are escaped', | ||
}, | ||
]; | ||
|
||
|
||
describe('Helper function html sanitize', () => { | ||
test('sanitize html list', () => { | ||
htmlSanitizeList.forEach((item) => { | ||
expect(sanitizeHtml(item.input)).toBe(item.expected); | ||
}); | ||
}); | ||
}); |
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