Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nodeca/js-yaml
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.12.0
Choose a base ref
...
head repository: nodeca/js-yaml
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3.13.1
Choose a head ref
  • 16 commits
  • 19 files changed
  • 5 contributors

Commits on Jun 1, 2018

  1. Travis-CI: increase tests timeout

    Vitaly Puzrin committed Jun 1, 2018
    Copy the full SHA
    2d1fbed View commit details

Commits on Dec 16, 2018

  1. Fix description of onWarning (#460)

    ajafff authored and Vitaly Puzrin committed Dec 16, 2018
    Copy the full SHA
    00bba11 View commit details

Commits on Jan 4, 2019

  1. Add "noArrayIndent" option (#461)

    Addresses issue #432 by adding a `noArrayIndent` option to optionally not add an extra level of indentation to array elements.
    
    When `noArrayIndent` option is set to `false` (or not provided), output is:
    ```
    array:
      - a
      - b
      - c
    ```
    
    When `noArrayIndent` option is set to `true`, output is:
    ```
    array:
    - a
    - b
    - c
    ```
    
    This helps avoid diffs when parsing, modifying, and generating valid yaml that does *not* use extra indentation for arrays.
    jacob-hd authored and Vitaly Puzrin committed Jan 4, 2019
    Copy the full SHA
    784d1d0 View commit details

Commits on Jan 5, 2019

  1. Browser files rebuild

    Vitaly Puzrin committed Jan 5, 2019
    Copy the full SHA
    7b68122 View commit details
  2. 3.12.1 released

    Vitaly Puzrin committed Jan 5, 2019
    Copy the full SHA
    b6d2609 View commit details

Commits on Feb 26, 2019

  1. Fix for issue #468 includes passing test (#469)

    diberry authored and Vitaly Puzrin committed Feb 26, 2019
    Copy the full SHA
    99c0bf9 View commit details
  2. Browser files rebuild

    Vitaly Puzrin committed Feb 26, 2019
    Copy the full SHA
    7231a49 View commit details
  3. 3.12.2 released

    Vitaly Puzrin committed Feb 26, 2019
    Copy the full SHA
    e4267fc View commit details

Commits on Mar 7, 2019

  1. Fix test name

    Vitaly Puzrin committed Mar 7, 2019
    Copy the full SHA
    59b6e76 View commit details

Commits on Mar 20, 2019

  1. Restrict data types for object keys

    fix #475
    rlidwka committed Mar 20, 2019
    Copy the full SHA
    a567ef3 View commit details
  2. Browser files rebuild

    Vitaly Puzrin committed Mar 20, 2019
    Copy the full SHA
    f64c673 View commit details
  3. 3.13.0 released

    Vitaly Puzrin committed Mar 20, 2019
    Copy the full SHA
    9d4ce5e View commit details

Commits on Apr 5, 2019

  1. Fix possible code execution in (already unsafe) load()

    ... when object with executable toString() property is used as a map key
    rlidwka committed Apr 5, 2019
    Copy the full SHA
    e18afbf View commit details
  2. Merge pull request #480 from nodeca/toString

    Fix possible code execution in (already unsafe) load()
    Vitaly Puzrin authored Apr 5, 2019
    Copy the full SHA
    b2f9e88 View commit details
  3. Browser files rebuild

    Vitaly Puzrin committed Apr 5, 2019
    Copy the full SHA
    da8ecf2 View commit details
  4. 3.13.1 released

    Vitaly Puzrin committed Apr 5, 2019
    Copy the full SHA
    665aadd View commit details
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
3.13.1 / 2019-04-05
-------------------

- Fix possible code execution in (already unsafe) `.load()`, #480.


3.13.0 / 2019-03-20
-------------------

- Security fix: `safeLoad()` can hang when arrays with nested refs
used as key. Now throws exception for nested arrays. #475.


3.12.2 / 2019-02-26
-------------------

- Fix `noArrayIndent` option for root level, #468.


3.12.1 / 2019-01-05
-------------------

- Added `noArrayIndent` option, #432.


3.12.0 / 2018-06-02
-------------------

3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -104,7 +104,7 @@ options:
- `filename` _(default: null)_ - string to be used as a file path in
error/warning messages.
- `onWarning` _(default: null)_ - function to call on warning messages.
Loader will throw on warnings if this function is not provided.
Loader will call this function with an instance of `YAMLException` for each warning.
- `schema` _(default: `DEFAULT_SAFE_SCHEMA`)_ - specifies a schema to use.
- `FAILSAFE_SCHEMA` - only strings, arrays and plain objects:
http://www.yaml.org/spec/1.2/spec.html#id2802346
@@ -170,6 +170,7 @@ disable exceptions by setting the `skipInvalid` option to `true`.
options:

- `indent` _(default: 2)_ - indentation width to use (in spaces).
- `noArrayIndent` _(default: false)_ - when true, will not add an indentation level to array elements
- `skipInvalid` _(default: false)_ - do not throw on invalid types (like function
in the safe schema) and skip pairs and single values with such types.
- `flowLevel` (default: -1) - specifies level of nesting, when to switch from
55 changes: 42 additions & 13 deletions dist/js-yaml.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* js-yaml 3.12.0 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/* js-yaml 3.13.1 https://github.com/nodeca/js-yaml */(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jsyaml = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
'use strict';


@@ -208,16 +208,17 @@ function encodeHex(character) {
}

function State(options) {
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
this.indent = Math.max(1, (options['indent'] || 2));
this.skipInvalid = options['skipInvalid'] || false;
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
this.sortKeys = options['sortKeys'] || false;
this.lineWidth = options['lineWidth'] || 80;
this.noRefs = options['noRefs'] || false;
this.noCompatMode = options['noCompatMode'] || false;
this.condenseFlow = options['condenseFlow'] || false;
this.schema = options['schema'] || DEFAULT_FULL_SCHEMA;
this.indent = Math.max(1, (options['indent'] || 2));
this.noArrayIndent = options['noArrayIndent'] || false;
this.skipInvalid = options['skipInvalid'] || false;
this.flowLevel = (common.isNothing(options['flowLevel']) ? -1 : options['flowLevel']);
this.styleMap = compileStyleMap(this.schema, options['styles'] || null);
this.sortKeys = options['sortKeys'] || false;
this.lineWidth = options['lineWidth'] || 80;
this.noRefs = options['noRefs'] || false;
this.noCompatMode = options['noCompatMode'] || false;
this.condenseFlow = options['condenseFlow'] || false;

this.implicitTypes = this.schema.compiledImplicit;
this.explicitTypes = this.schema.compiledExplicit;
@@ -837,13 +838,14 @@ function writeNode(state, level, object, block, compact, iskey) {
}
}
} else if (type === '[object Array]') {
var arrayLevel = (state.noArrayIndent && (level > 0)) ? level - 1 : level;
if (block && (state.dump.length !== 0)) {
writeBlockSequence(state, level, state.dump, compact);
writeBlockSequence(state, arrayLevel, state.dump, compact);
if (duplicate) {
state.dump = '&ref_' + duplicateIndex + state.dump;
}
} else {
writeFlowSequence(state, level, state.dump);
writeFlowSequence(state, arrayLevel, state.dump);
if (duplicate) {
state.dump = '&ref_' + duplicateIndex + ' ' + state.dump;
}
@@ -1005,6 +1007,8 @@ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;


function _class(obj) { return Object.prototype.toString.call(obj); }

function is_EOL(c) {
return (c === 0x0A/* LF */) || (c === 0x0D/* CR */);
}
@@ -1260,6 +1264,31 @@ function mergeMappings(state, destination, source, overridableKeys) {
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startPos) {
var index, quantity;

// The output is a plain object here, so keys can only be strings.
// We need to convert keyNode to a string, but doing so can hang the process
// (deeply nested arrays that explode exponentially using aliases).
if (Array.isArray(keyNode)) {
keyNode = Array.prototype.slice.call(keyNode);

for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
if (Array.isArray(keyNode[index])) {
throwError(state, 'nested arrays are not supported inside keys');
}

if (typeof keyNode === 'object' && _class(keyNode[index]) === '[object Object]') {
keyNode[index] = '[object Object]';
}
}
}

// Avoid code execution in load() via toString property
// (still use its own toString for arrays, timestamps,
// and whatever user schema extensions happen to have @@toStringTag)
if (typeof keyNode === 'object' && _class(keyNode) === '[object Object]') {
keyNode = '[object Object]';
}


keyNode = String(keyNode);

if (_result === null) {
Loading