-
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Completes prior fix 366 for script sanitization
* Some cases missed, per: http://stackoverflow.com/a/23983448/1009332 * Added serverRendering and port to railsContext * Only logging attributes client side if tracing to avoid overwhelming server logs. On the client, one can optionally toggle expand the props. On the server, we stringified, and with a big set of props, that could be huge.
- Loading branch information
Showing
12 changed files
with
93 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
export default (val) => { | ||
// Replace closing | ||
const re = /<\/\W*script\W*>/gi; | ||
return val.replace(re, '(/script)'); | ||
const re = /<\/\W*script/gi; | ||
return val.replace(re, '(/script'); | ||
}; |
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,11 +1,47 @@ | ||
import test from 'tape'; | ||
import scriptSanitizedVal, { consoleReplay } from '../src/scriptSanitizedVal'; | ||
|
||
test('scriptSanitizedVal returns no </script>', (assert) => { | ||
test('scriptSanitizedVal returns no </script if spaces, uppercase 1', (assert) => { | ||
assert.plan(1); | ||
const input = '[SERVER] This is a script:\"</div>\"</script> <script>alert(\'WTF\')</ SCRIPT >'; | ||
const actual = scriptSanitizedVal(input); | ||
const expected = '[SERVER] This is a script:\"</div>\"(/script) <script>alert(\'WTF\')(/script)';; | ||
const expected = '[SERVER] This is a script:\"</div>\"(/script> <script>alert(\'WTF\')(/script >'; | ||
assert.equals(actual, expected, | ||
'consoleReplay should return an empty string if no console.history'); | ||
'scriptSanitizedVal replaces closing script tags'); | ||
}); | ||
|
||
test('scriptSanitizedVal returns no </script> 2', (assert) => { | ||
assert.plan(1); | ||
const input = 'Script2:"</div>"</script xx> <script>alert(\'WTF2\')</script xx>'; | ||
const actual = scriptSanitizedVal(input); | ||
const expected = 'Script2:"</div>"(/script xx> <script>alert(\'WTF2\')(/script xx>'; | ||
assert.equals(actual, expected, | ||
'scriptSanitizedVal replaces closing script tags'); | ||
}); | ||
|
||
test('scriptSanitizedVal returns no </script> 3', (assert) => { | ||
assert.plan(1); | ||
const input = 'Script3:"</div>"</ SCRIPT xx> <script>alert(\'WTF3\')</script xx>'; | ||
const actual = scriptSanitizedVal(input); | ||
const expected = 'Script3:"</div>"(/script xx> <script>alert(\'WTF3\')(/script xx>'; | ||
assert.equals(actual, expected, | ||
'scriptSanitizedVal replaces closing script tags'); | ||
}); | ||
|
||
test('scriptSanitizedVal returns no </script> 4', (assert) => { | ||
assert.plan(1); | ||
const input = 'Script4"</div>"</script <script>alert(\'WTF4\')</script>'; | ||
const actual = scriptSanitizedVal(input); | ||
const expected = 'Script4"</div>"(/script <script>alert(\'WTF4\')(/script>'; | ||
assert.equals(actual, expected, | ||
'scriptSanitizedVal replaces closing script tags'); | ||
}); | ||
|
||
test('scriptSanitizedVal returns no </script> 5', (assert) => { | ||
assert.plan(1); | ||
const input = 'Script5:"</div>"</ script> <script>alert(\'WTF5\')</script>'; | ||
const actual = scriptSanitizedVal(input); | ||
const expected = 'Script5:"</div>"(/script> <script>alert(\'WTF5\')(/script>'; | ||
assert.equals(actual, expected, | ||
'scriptSanitizedVal replaces closing script tags'); | ||
}); |
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