Skip to content

Commit cb14c0b

Browse files
committed
Fix parsing of quotes followed by newlines.
1 parent 2bf232b commit cb14c0b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/js-yaml/loader.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,9 @@ function readSingleQuotedScalar(state, nodeIndent) {
532532
ch = state.input.charCodeAt(++state.position);
533533

534534
if (ch === 0x27/* ' */) {
535-
captureStart = captureEnd = state.position;
535+
captureStart = state.position;
536536
state.position++;
537+
captureEnd = state.position;
537538
} else {
538539
return true;
539540
}

test/issues/0303.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
var assert = require('assert');
4+
var yaml = require('../../');
5+
6+
test('Loader should not strip quotes before newlines', function () {
7+
var with_space = yaml.load("'''foo'' '");
8+
var with_newline = yaml.load("'''foo''\n'");
9+
assert.strictEqual(with_space, "'foo' ");
10+
assert.strictEqual(with_newline, "'foo' ");
11+
});

0 commit comments

Comments
 (0)