-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Subscribers: validate urls (#7540)
no issue - Ensure URLs submitted via form are sanitized so that we only accept real urls - Add some tests for the isEmptyOrURL validator
- Loading branch information
Showing
2 changed files
with
40 additions
and
2 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var should = require('should'), | ||
|
||
validation = require('../../server/data/validation'); | ||
|
||
// Validate our customisations | ||
describe('Validation', function () { | ||
it('should export our required functions', function () { | ||
should.exist(validation); | ||
|
||
validation.should.have.properties( | ||
['validate', 'validator', 'validateSchema', 'validateSettings', 'validateActiveTheme'] | ||
); | ||
|
||
validation.validate.should.be.a.Function(); | ||
validation.validateSchema.should.be.a.Function(); | ||
validation.validateSettings.should.be.a.Function(); | ||
validation.validateActiveTheme.should.be.a.Function(); | ||
|
||
validation.validator.should.have.properties(['empty', 'notContains', 'isTimezone', 'isEmptyOrURL', 'isSlug']); | ||
}); | ||
|
||
describe('Validator customisations', function () { | ||
var validator = validation.validator; | ||
|
||
it('isEmptyOrUrl filters javascript urls', function () { | ||
/*jshint scripturl:true */ | ||
validator.isEmptyOrURL('javascript:alert(0)').should.be.false(); | ||
/*jshint scripturl:false */ | ||
validator.isEmptyOrURL('').should.be.true(); | ||
validator.isEmptyOrURL('http://localhost:2368').should.be.true(); | ||
}); | ||
}); | ||
}); |