Skip to content

Commit

Permalink
Use safe mode and null base by default in canonize.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlongley committed Aug 23, 2022
1 parent 6f9c6fe commit 0229176
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# jsonld ChangeLog

## 8.0.0 - 2022-08-xx

### Changed
- **BREAKING**: By default, set safe mode to `true` and `base` to
`null` in `canonize`.

## 7.0.0 - 2022-08-16

### Fixed
Expand Down
13 changes: 10 additions & 3 deletions lib/jsonld.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,12 +524,18 @@ jsonld.link = async function(input, ctx, options) {
* unless the 'inputFormat' option is used. The output is an RDF dataset
* unless the 'format' option is used.
*
* Note: Canonicalization sets `safe` to `true` and `base` to `null` by
* default in order to produce safe outputs and "fail closed" by default. This
* is different from the other API transformations in this version which
* allow unsafe defaults (for cryptographic usage) in order to comply with the
* JSON-LD 1.1 specification.
*
* @param input the input to normalize as JSON-LD or as a format specified by
* the 'inputFormat' option.
* @param [options] the options to use:
* [algorithm] the normalization algorithm to use, `URDNA2015` or
* `URGNA2012` (default: `URDNA2015`).
* [base] the base IRI to use.
* [base] the base IRI to use (default: `null`).
* [expandContext] a context to expand with.
* [skipExpansion] true to assume the input is expanded and skip
* expansion, false not to, defaults to false.
Expand All @@ -539,7 +545,7 @@ jsonld.link = async function(input, ctx, options) {
* 'application/n-quads' for N-Quads.
* [documentLoader(url, options)] the document loader.
* [useNative] true to use a native canonize algorithm
* [safe] true to use safe mode. (default: false)
* [safe] true to use safe mode. (default: true).
* [contextResolver] internal use only.
*
* @return a Promise that resolves to the normalized output.
Expand All @@ -551,9 +557,10 @@ jsonld.normalize = jsonld.canonize = async function(input, options) {

// set default options
options = _setDefaults(options, {
base: _isString(input) ? input : '',
base: _isString(input) ? input : null,
algorithm: 'URDNA2015',
skipExpansion: false,
safe: true,
contextResolver: new ContextResolver(
{sharedCache: _resolvedContextCache})
});
Expand Down

0 comments on commit 0229176

Please sign in to comment.