yaml 2.4.2 → 2.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/dist/parse/lexer.js +10 -3
- package/browser/dist/schema/core/float.js +1 -1
- package/browser/dist/schema/yaml-1.1/float.js +1 -1
- package/browser/dist/stringify/stringifyPair.js +1 -1
- package/dist/parse/lexer.js +10 -3
- package/dist/schema/core/float.js +1 -1
- package/dist/schema/yaml-1.1/float.js +1 -1
- package/dist/stringify/stringifyPair.js +1 -1
- package/package.json +1 -1
|
@@ -149,6 +149,8 @@ class Lexer {
|
|
|
149
149
|
*/
|
|
150
150
|
*lex(source, incomplete = false) {
|
|
151
151
|
if (source) {
|
|
152
|
+
if (typeof source !== 'string')
|
|
153
|
+
throw TypeError('source is not a string');
|
|
152
154
|
this.buffer = this.buffer ? this.buffer + source : source;
|
|
153
155
|
this.lineEndPos = null;
|
|
154
156
|
}
|
|
@@ -248,11 +250,16 @@ class Lexer {
|
|
|
248
250
|
}
|
|
249
251
|
if (line[0] === '%') {
|
|
250
252
|
let dirEnd = line.length;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
+
let cs = line.indexOf('#');
|
|
254
|
+
while (cs !== -1) {
|
|
253
255
|
const ch = line[cs - 1];
|
|
254
|
-
if (ch === ' ' || ch === '\t')
|
|
256
|
+
if (ch === ' ' || ch === '\t') {
|
|
255
257
|
dirEnd = cs - 1;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
cs = line.indexOf('#', cs + 1);
|
|
262
|
+
}
|
|
256
263
|
}
|
|
257
264
|
while (true) {
|
|
258
265
|
const ch = line[dirEnd - 1];
|
|
@@ -5,7 +5,7 @@ const floatNaN = {
|
|
|
5
5
|
identify: value => typeof value === 'number',
|
|
6
6
|
default: true,
|
|
7
7
|
tag: 'tag:yaml.org,2002:float',
|
|
8
|
-
test: /^(?:[-+]?\.(?:inf|Inf|INF
|
|
8
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
9
9
|
resolve: str => str.slice(-3).toLowerCase() === 'nan'
|
|
10
10
|
? NaN
|
|
11
11
|
: str[0] === '-'
|
|
@@ -5,7 +5,7 @@ const floatNaN = {
|
|
|
5
5
|
identify: value => typeof value === 'number',
|
|
6
6
|
default: true,
|
|
7
7
|
tag: 'tag:yaml.org,2002:float',
|
|
8
|
-
test: /^[-+]?\.(?:inf|Inf|INF
|
|
8
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
9
9
|
resolve: (str) => str.slice(-3).toLowerCase() === 'nan'
|
|
10
10
|
? NaN
|
|
11
11
|
: str[0] === '-'
|
|
@@ -10,7 +10,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
10
10
|
if (keyComment) {
|
|
11
11
|
throw new Error('With simple keys, key nodes cannot have comments');
|
|
12
12
|
}
|
|
13
|
-
if (isCollection(key)) {
|
|
13
|
+
if (isCollection(key) || (!isNode(key) && typeof key === 'object')) {
|
|
14
14
|
const msg = 'With simple keys, collection cannot be used as a key value';
|
|
15
15
|
throw new Error(msg);
|
|
16
16
|
}
|
package/dist/parse/lexer.js
CHANGED
|
@@ -151,6 +151,8 @@ class Lexer {
|
|
|
151
151
|
*/
|
|
152
152
|
*lex(source, incomplete = false) {
|
|
153
153
|
if (source) {
|
|
154
|
+
if (typeof source !== 'string')
|
|
155
|
+
throw TypeError('source is not a string');
|
|
154
156
|
this.buffer = this.buffer ? this.buffer + source : source;
|
|
155
157
|
this.lineEndPos = null;
|
|
156
158
|
}
|
|
@@ -250,11 +252,16 @@ class Lexer {
|
|
|
250
252
|
}
|
|
251
253
|
if (line[0] === '%') {
|
|
252
254
|
let dirEnd = line.length;
|
|
253
|
-
|
|
254
|
-
|
|
255
|
+
let cs = line.indexOf('#');
|
|
256
|
+
while (cs !== -1) {
|
|
255
257
|
const ch = line[cs - 1];
|
|
256
|
-
if (ch === ' ' || ch === '\t')
|
|
258
|
+
if (ch === ' ' || ch === '\t') {
|
|
257
259
|
dirEnd = cs - 1;
|
|
260
|
+
break;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
cs = line.indexOf('#', cs + 1);
|
|
264
|
+
}
|
|
258
265
|
}
|
|
259
266
|
while (true) {
|
|
260
267
|
const ch = line[dirEnd - 1];
|
|
@@ -7,7 +7,7 @@ const floatNaN = {
|
|
|
7
7
|
identify: value => typeof value === 'number',
|
|
8
8
|
default: true,
|
|
9
9
|
tag: 'tag:yaml.org,2002:float',
|
|
10
|
-
test: /^(?:[-+]?\.(?:inf|Inf|INF
|
|
10
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
11
11
|
resolve: str => str.slice(-3).toLowerCase() === 'nan'
|
|
12
12
|
? NaN
|
|
13
13
|
: str[0] === '-'
|
|
@@ -7,7 +7,7 @@ const floatNaN = {
|
|
|
7
7
|
identify: value => typeof value === 'number',
|
|
8
8
|
default: true,
|
|
9
9
|
tag: 'tag:yaml.org,2002:float',
|
|
10
|
-
test: /^[-+]?\.(?:inf|Inf|INF
|
|
10
|
+
test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
|
|
11
11
|
resolve: (str) => str.slice(-3).toLowerCase() === 'nan'
|
|
12
12
|
? NaN
|
|
13
13
|
: str[0] === '-'
|
|
@@ -12,7 +12,7 @@ function stringifyPair({ key, value }, ctx, onComment, onChompKeep) {
|
|
|
12
12
|
if (keyComment) {
|
|
13
13
|
throw new Error('With simple keys, key nodes cannot have comments');
|
|
14
14
|
}
|
|
15
|
-
if (identity.isCollection(key)) {
|
|
15
|
+
if (identity.isCollection(key) || (!identity.isNode(key) && typeof key === 'object')) {
|
|
16
16
|
const msg = 'With simple keys, collection cannot be used as a key value';
|
|
17
17
|
throw new Error(msg);
|
|
18
18
|
}
|