-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from sunrise/pe/escape-attendee-name
Person’s CN escaping
- Loading branch information
Showing
8 changed files
with
80 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
exports.escape = function(str) { | ||
str = str || ''; | ||
return str.replace(/\n/g, '\\n').replace(/;/g, '\\;').replace(/,/g, '\\,').replace(/"/g, '\\"'); | ||
}; | ||
|
||
exports.unescape = function(str) { | ||
return str.replace(/\\n/g, '\n').replace(/\\;/g, ';').replace(/\\,/g, ',').replace(/\\"/g, '"'); | ||
}; |
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,48 @@ | ||
var assert = require('assert'); | ||
var helpers = require('../../lib/vobject/helpers'); | ||
|
||
describe('lib/vobject/helpers.js', function() { | ||
describe('escape', function() { | ||
it('should escape newline', function() { | ||
var str = 'this\nthat'; | ||
assert.equal(helpers.escape(str), 'this\\nthat'); | ||
}); | ||
|
||
it('should escape semicolon', function() { | ||
var str = 'this;that'; | ||
assert.equal(helpers.escape(str), 'this\\;that'); | ||
}); | ||
|
||
it('should escape comma', function() { | ||
var str = 'this,that'; | ||
assert.equal(helpers.escape(str), 'this\\,that'); | ||
}); | ||
|
||
it('should escape double quote', function() { | ||
var str = 'this"that'; | ||
assert.equal(helpers.escape(str), 'this\\"that'); | ||
}); | ||
}); | ||
|
||
describe('unescape', function() { | ||
it('should unescape newline', function() { | ||
var str = 'this\\nthat'; | ||
assert.equal(helpers.unescape(str), 'this\nthat'); | ||
}); | ||
|
||
it('should unescape semicolon', function() { | ||
var str = 'this\\;that'; | ||
assert.equal(helpers.unescape(str), 'this;that'); | ||
}); | ||
|
||
it('should unescape comma', function() { | ||
var str = 'this\\,that'; | ||
assert.equal(helpers.unescape(str), 'this,that'); | ||
}); | ||
|
||
it('should unescape double quote', function() { | ||
var str = 'this\\"that'; | ||
assert.equal(helpers.unescape(str), 'this"that'); | ||
}); | ||
}); | ||
}); |
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