-
-
Notifications
You must be signed in to change notification settings - Fork 770
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
According to YAML 1.2 spec, #xD800-#xDFFF unicode range is considered non-printables. But unicode range #x10000-#x10FFFF, represented in UTF-16 by the same characters is not. NOTE: Non-printable characters are still allowed in quoted scalars, added a pending test for this case. Fixes: #191
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
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,25 @@ | ||
'use strict'; | ||
|
||
|
||
var assert = require('assert'); | ||
var yaml = require('../../'); | ||
|
||
|
||
test('Allow astral characters', function () { | ||
assert.deepEqual(yaml.load('πππ¦: π£πππ’π'), { 'πππ¦': 'π£πππ’π' }); | ||
}); | ||
|
||
test('Forbid non-printable characters', function () { | ||
assert.throws(function () { yaml.load('\x01'); }, yaml.YAMLException); | ||
assert.throws(function () { yaml.load('\x7f'); }, yaml.YAMLException); | ||
assert.throws(function () { yaml.load('\x9f'); }, yaml.YAMLException); | ||
}); | ||
|
||
test('Forbid lone surrogates', function () { | ||
assert.throws(function () { yaml.load('\udc00\ud800'); }, yaml.YAMLException); | ||
}); | ||
|
||
test.skip('Allow non-printable characters inside quoted scalars', function () { | ||
assert.strictEqual(yaml.load('"\x7f\x9f\udc00\ud800"'), '\x7f\x9f\udc00\ud800'); | ||
}); | ||
|