[Pkg-javascript-commits] [node-js-yaml] 04/06: New upstream version 3.7.0+dfsg

Jérémy Lal kapouer at moszumanska.debian.org
Sat Nov 12 09:14:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

kapouer pushed a commit to branch master
in repository node-js-yaml.

commit b9f93c3408545bdcb52aff34a074a6786275e02d
Author: Jérémy Lal <kapouer at melix.org>
Date:   Sat Nov 12 10:09:10 2016 +0100

    New upstream version 3.7.0+dfsg
---
 CHANGELOG.md               |  7 +++++++
 lib/js-yaml/dumper.js      |  3 +--
 lib/js-yaml/loader.js      |  7 ++++---
 lib/js-yaml/schema.js      | 12 ++++++++----
 package.json               |  2 +-
 test/issues/0303.js        | 11 +++++++++++
 test/units/tagmultikind.js | 39 +++++++++++++++++++++++++++++++++++++++
 7 files changed, 71 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index da9facb..103b1bb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+3.7.0 / 2016-11-12
+------------------
+
+- Fix parsing of quotes followed by newlines (#304, thanks to @dplepage).
+- Support polymorphism for tags (#300, thanks to @monken).
+
+
 3.6.1 / 2016-05-11
 ------------------
 
diff --git a/lib/js-yaml/dumper.js b/lib/js-yaml/dumper.js
index 41d3d45..203f436 100644
--- a/lib/js-yaml/dumper.js
+++ b/lib/js-yaml/dumper.js
@@ -71,8 +71,7 @@ function compileStyleMap(schema, map) {
     if (tag.slice(0, 2) === '!!') {
       tag = 'tag:yaml.org,2002:' + tag.slice(2);
     }
-
-    type = schema.compiledTypeMap[tag];
+    type = schema.compiledTypeMap['fallback'][tag];
 
     if (type && _hasOwnProperty.call(type.styleAliases, style)) {
       style = type.styleAliases[style];
diff --git a/lib/js-yaml/loader.js b/lib/js-yaml/loader.js
index 8966d6b..70e1a56 100644
--- a/lib/js-yaml/loader.js
+++ b/lib/js-yaml/loader.js
@@ -532,8 +532,9 @@ function readSingleQuotedScalar(state, nodeIndent) {
       ch = state.input.charCodeAt(++state.position);
 
       if (ch === 0x27/* ' */) {
-        captureStart = captureEnd = state.position;
+        captureStart = state.position;
         state.position++;
+        captureEnd = state.position;
       } else {
         return true;
       }
@@ -1378,8 +1379,8 @@ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact
           break;
         }
       }
-    } else if (_hasOwnProperty.call(state.typeMap, state.tag)) {
-      type = state.typeMap[state.tag];
+    } else if (_hasOwnProperty.call(state.typeMap[state.kind || 'fallback'], state.tag)) {
+      type = state.typeMap[state.kind || 'fallback'][state.tag];
 
       if (state.result !== null && type.kind !== state.kind) {
         throwError(state, 'unacceptable node kind for !<' + state.tag + '> tag; it should be "' + type.kind + '", not "' + state.kind + '"');
diff --git a/lib/js-yaml/schema.js b/lib/js-yaml/schema.js
index 32803ff..ca7cf47 100644
--- a/lib/js-yaml/schema.js
+++ b/lib/js-yaml/schema.js
@@ -16,7 +16,7 @@ function compileList(schema, name, result) {
 
   schema[name].forEach(function (currentType) {
     result.forEach(function (previousType, previousIndex) {
-      if (previousType.tag === currentType.tag) {
+      if (previousType.tag === currentType.tag && previousType.kind === currentType.kind) {
         exclude.push(previousIndex);
       }
     });
@@ -31,16 +31,20 @@ function compileList(schema, name, result) {
 
 
 function compileMap(/* lists... */) {
-  var result = {}, index, length;
+  var result = {
+        scalar: {},
+        sequence: {},
+        mapping: {},
+        fallback: {}
+      }, index, length;
 
   function collectType(type) {
-    result[type.tag] = type;
+    result[type.kind][type.tag] = result['fallback'][type.tag] = type;
   }
 
   for (index = 0, length = arguments.length; index < length; index += 1) {
     arguments[index].forEach(collectType);
   }
-
   return result;
 }
 
diff --git a/package.json b/package.json
index 1ec09ff..1c6deb1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "name": "js-yaml",
-  "version": "3.6.1",
+  "version": "3.7.0",
   "description": "YAML 1.2 parser and serializer",
   "keywords": [
     "yaml",
diff --git a/test/issues/0303.js b/test/issues/0303.js
new file mode 100644
index 0000000..748d03e
--- /dev/null
+++ b/test/issues/0303.js
@@ -0,0 +1,11 @@
+'use strict';
+
+var assert = require('assert');
+var yaml   = require('../../');
+
+test('Loader should not strip quotes before newlines', function () {
+  var with_space = yaml.load("'''foo'' '");
+  var with_newline = yaml.load("'''foo''\n'");
+  assert.strictEqual(with_space, "'foo' ");
+  assert.strictEqual(with_newline, "'foo' ");
+});
diff --git a/test/units/tagmultikind.js b/test/units/tagmultikind.js
new file mode 100644
index 0000000..662e7cc
--- /dev/null
+++ b/test/units/tagmultikind.js
@@ -0,0 +1,39 @@
+'use strict';
+
+
+var assert = require('assert');
+var yaml = require('../../');
+
+var tags = [ {
+  tag: 'Include',
+  type: 'scalar'
+}, {
+  tag: 'Include',
+  type: 'mapping'
+} ].map(function (fn) {
+  return new yaml.Type('!' + fn.tag, {
+    kind: fn.type,
+    resolve: function () {
+      return true;
+    },
+    construct: function (obj) {
+      return obj;
+    }
+  });
+});
+
+var schema = yaml.Schema.create(tags);
+
+
+test('Process tag with kind: scalar', function () {
+  assert.deepEqual(yaml.safeLoad('!Include foobar', {
+    schema: schema
+  }), 'foobar');
+});
+
+
+test('Process tag with kind: mapping', function () {
+  assert.deepEqual(yaml.safeLoad('!Include\n  location: foobar', {
+    schema: schema
+  }), { location: 'foobar' });
+});

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-js-yaml.git



More information about the Pkg-javascript-commits mailing list