diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-27 19:33:54 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-27 19:34:16 +0100 |
commit | 0e6de2c31dbf8c21277481f112e99c52b913940f (patch) | |
tree | 91789032de3b8eec9d789acd1323f25fc5d08422 /node_modules/js-yaml/lib | |
parent | ceda0da31ad542c598c68146ae0712ca03df3d71 (diff) |
node_modules
Diffstat (limited to 'node_modules/js-yaml/lib')
-rw-r--r-- | node_modules/js-yaml/lib/js-yaml/dumper.js | 16 | ||||
-rw-r--r-- | node_modules/js-yaml/lib/js-yaml/loader.js | 2 |
2 files changed, 14 insertions, 4 deletions
diff --git a/node_modules/js-yaml/lib/js-yaml/dumper.js b/node_modules/js-yaml/lib/js-yaml/dumper.js index 6e60bbd01..025b18552 100644 --- a/node_modules/js-yaml/lib/js-yaml/dumper.js +++ b/node_modules/js-yaml/lib/js-yaml/dumper.js @@ -461,11 +461,21 @@ function foldLine(line, width) { // Escapes a double-quoted string. function escapeString(string) { var result = ''; - var char; + var char, nextChar; var escapeSeq; for (var i = 0; i < string.length; i++) { char = string.charCodeAt(i); + // Check for surrogate pairs (reference Unicode 3.0 section "3.7 Surrogates"). + if (char >= 0xD800 && char <= 0xDBFF/* high surrogate */) { + nextChar = string.charCodeAt(i + 1); + if (nextChar >= 0xDC00 && nextChar <= 0xDFFF/* low surrogate */) { + // Combine the surrogate pair and store it escaped. + result += encodeHex((char - 0xD800) * 0x400 + nextChar - 0xDC00 + 0x10000); + // Advance index one extra since we already used that char here. + i++; continue; + } + } escapeSeq = ESCAPE_SEQUENCES[char]; result += !escapeSeq && isPrintable(char) ? string[i] @@ -531,7 +541,7 @@ function writeFlowMapping(state, level, object) { pairBuffer; for (index = 0, length = objectKeyList.length; index < length; index += 1) { - pairBuffer = ''; + pairBuffer = state.condenseFlow ? '"' : ''; if (index !== 0) pairBuffer += ', '; @@ -544,7 +554,7 @@ function writeFlowMapping(state, level, object) { if (state.dump.length > 1024) pairBuffer += '? '; - pairBuffer += state.dump + ':' + (state.condenseFlow ? '' : ' '); + pairBuffer += state.dump + (state.condenseFlow ? '"' : '') + ':' + (state.condenseFlow ? '' : ' '); if (!writeNode(state, level, objectValue, false, false)) { continue; // Skip this pair because of invalid value. diff --git a/node_modules/js-yaml/lib/js-yaml/loader.js b/node_modules/js-yaml/lib/js-yaml/loader.js index 9188da1f5..fe2cb4d07 100644 --- a/node_modules/js-yaml/lib/js-yaml/loader.js +++ b/node_modules/js-yaml/lib/js-yaml/loader.js @@ -997,7 +997,7 @@ function readBlockMapping(state, nodeIndent, flowIndent) { allowCompact = true; } else { - throwError(state, 'incomplete explicit mapping pair; a key node is missed'); + throwError(state, 'incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line'); } state.position += 1; |