diff --git a/CHANGELOG.md b/CHANGELOG.md index e2bab714999..49d686356e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. -7.7.2
+7.7.3
+7.7.2
7.7.1
7.7.0
7.6.0
diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js index 7e56b5fba6e..2b8d2c36a81 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js @@ -7,7 +7,7 @@ const inputs = require('../fixtures/url-inputs.js').searchParams; const bench = common.createBenchmark(main, { type: Object.keys(inputs), method: ['legacy', 'whatwg'], - n: [1e5] + n: [1e6] }); function useLegacy(n, input, prop) { diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 7ea5a6ea98c..7c1f5373d99 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -135,8 +135,9 @@ added: v0.1.90 understand the `-c` switch on UNIX or `/d /s /c` on Windows. On Windows, command line parsing should be compatible with `cmd.exe`.) * `timeout` {number} (Default: `0`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed (Default: `200*1024`) + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `killSignal` {string|integer} (Default: `'SIGTERM'`) * `uid` {number} Sets the user identity of the process. (See setuid(2).) * `gid` {number} Sets the group identity of the process. (See setgid(2).) @@ -212,8 +213,9 @@ added: v0.1.91 * `env` {Object} Environment key-value pairs * `encoding` {string} (Default: `'utf8'`) * `timeout` {number} (Default: `0`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed (Default: `200*1024`) + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `killSignal` {string|integer} (Default: `'SIGTERM'`) * `uid` {number} Sets the user identity of the process. (See setuid(2).) * `gid` {number} Sets the group identity of the process. (See setgid(2).) @@ -618,8 +620,9 @@ changes: is allowed to run. (Default: `undefined`) * `killSignal` {string|integer} The signal value to be used when the spawned process will be killed. (Default: `'SIGTERM'`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`) * Returns: {Buffer|string} The stdout from the command @@ -664,8 +667,9 @@ changes: is allowed to run. (Default: `undefined`) * `killSignal` {string|integer} The signal value to be used when the spawned process will be killed. (Default: `'SIGTERM'`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`) * Returns: {Buffer|string} The stdout from the command @@ -716,8 +720,9 @@ changes: is allowed to run. (Default: `undefined`) * `killSignal` {string|integer} The signal value to be used when the spawned process will be killed. (Default: `'SIGTERM'`) - * [`maxBuffer`][] {number} largest amount of data (in bytes) allowed on - stdout or stderr - if exceeded child process is killed + * `maxBuffer` {number} Largest amount of data in bytes allowed on stdout or + stderr. (Default: `200*1024`) If exceeded, the child process is terminated. + See caveat at [`maxBuffer` and Unicode][]. * `encoding` {string} The encoding used for all stdio inputs and outputs. (Default: `'buffer'`) * `shell` {boolean|string} If `true`, runs `command` inside of a shell. Uses @@ -1235,7 +1240,7 @@ to `stdout` although there are only 4 characters. [`Error`]: errors.html#errors_class_error [`EventEmitter`]: events.html#events_class_eventemitter [`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify -[`maxBuffer`]: #child_process_maxbuffer_and_unicode +[`maxBuffer` and Unicode]: #child_process_maxbuffer_and_unicode [`net.Server`]: net.html#net_class_net_server [`net.Socket`]: net.html#net_class_net_socket [`options.detached`]: #child_process_options_detached diff --git a/doc/api/crypto.md b/doc/api/crypto.md index e901edf5fd3..9557273a9b7 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -62,11 +62,9 @@ const cert2 = crypto.Certificate(); - -The `spkac` data structure includes a public key and a challenge. The -`certificate.exportChallenge()` returns the challenge component in the -form of a Node.js [`Buffer`][]. The `spkac` argument can be either a string -or a [`Buffer`][]. +- `spkac` {string | Buffer} +- Returns {Buffer} The challenge component of the `spkac` data structure, which +includes a public key and a challenge. ```js const cert = require('crypto').Certificate(); @@ -80,11 +78,9 @@ console.log(challenge.toString('utf8')); - -The `spkac` data structure includes a public key and a challenge. The -`certificate.exportPublicKey()` returns the public key component in the -form of a Node.js [`Buffer`][]. The `spkac` argument can be either a string -or a [`Buffer`][]. +- `spkac` {string | Buffer} +- Returns {Buffer} The public key component of the `spkac` data structure, +which includes a public key and a challenge. ```js const cert = require('crypto').Certificate(); @@ -98,9 +94,9 @@ console.log(publicKey); - -Returns `true` if the given `spkac` data structure is valid, `false` otherwise. -The `spkac` argument must be a Node.js [`Buffer`][]. +- `spkac` {Buffer} +- Returns {boolean} `true` if the given `spkac` data structure is valid, `false` +otherwise. ```js const cert = require('crypto').Certificate(); @@ -176,6 +172,7 @@ console.log(encrypted); +- `output_encoding` {string} Returns any remaining enciphered contents. If `output_encoding` parameter is one of `'latin1'`, `'base64'` or `'hex'`, a string is returned. @@ -189,6 +186,8 @@ once will result in an error being thrown. +- `buffer` {Buffer} +- Returns the {Cipher} for method chaining. When using an authenticated encryption mode (only `GCM` is currently supported), the `cipher.setAAD()` method sets the value used for the @@ -196,8 +195,6 @@ _additional authenticated data_ (AAD) input parameter. The `cipher.setAAD()` method must be called before [`cipher.update()`][]. -Returns `this` for method chaining. - ### cipher.getAuthTag() +- `auto_padding` {boolean} Defaults to `true`. +- Returns the {Cipher} for method chaining. When using block encryption algorithms, the `Cipher` class will automatically add padding to the input data to the appropriate block size. To disable the @@ -227,8 +226,6 @@ using `0x0` instead of PKCS padding. The `cipher.setAutoPadding()` method must be called before [`cipher.final()`][]. -Returns `this` for method chaining. - ### cipher.update(data[, input_encoding][, output_encoding]) +- `data` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Updates the cipher with `data`. If the `input_encoding` argument is given, its value must be one of `'utf8'`, `'ascii'`, or `'latin1'` and the `data` @@ -322,6 +322,7 @@ console.log(decrypted); +- `output_encoding` {string} Returns any remaining deciphered contents. If `output_encoding` parameter is one of `'latin1'`, `'ascii'` or `'utf8'`, a string is returned. @@ -339,6 +340,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/9398 description: This method now returns a reference to `decipher`. --> +- `buffer` {Buffer} +- Returns the {Cipher} for method chaining. When using an authenticated encryption mode (only `GCM` is currently supported), the `decipher.setAAD()` method sets the value used for the @@ -346,8 +349,6 @@ _additional authenticated data_ (AAD) input parameter. The `decipher.setAAD()` method must be called before [`decipher.update()`][]. -Returns `this` for method chaining. - ### decipher.setAuthTag(buffer) +- `buffer` {Buffer} +- Returns the {Cipher} for method chaining. When using an authenticated encryption mode (only `GCM` is currently supported), the `decipher.setAuthTag()` method is used to pass in the @@ -366,12 +369,12 @@ cipher text should be discarded due to failed authentication. The `decipher.setAuthTag()` method must be called before [`decipher.final()`][]. -Returns `this` for method chaining. - -### decipher.setAutoPadding(auto_padding=true) +### decipher.setAutoPadding([auto_padding]) +- `auto_padding` {boolean} Defaults to `true`. +- Returns the {Cipher} for method chaining. When data has been encrypted without standard block padding, calling `decipher.setAutoPadding(false)` will disable automatic padding to prevent @@ -383,8 +386,6 @@ multiple of the ciphers block size. The `decipher.setAutoPadding()` method must be called before [`decipher.final()`][]. -Returns `this` for method chaining. - ### decipher.update(data[, input_encoding][, output_encoding]) +- `data` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Updates the decipher with `data`. If the `input_encoding` argument is given, its value must be one of `'latin1'`, `'base64'`, or `'hex'` and the `data` @@ -444,6 +448,9 @@ assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); +- `other_public_key` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Computes the shared secret using `other_public_key` as the other party's public key and returns the computed shared secret. The supplied @@ -459,6 +466,7 @@ If `output_encoding` is given a string is returned; otherwise, a +- `encoding` {string} Generates private and public Diffie-Hellman key values, and returns the public key in the specified `encoding`. This key should be @@ -470,6 +478,7 @@ or `'base64'`. If `encoding` is provided a string is returned; otherwise a +- `encoding` {string} Returns the Diffie-Hellman generator in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is @@ -479,6 +488,7 @@ returned; otherwise a [`Buffer`][] is returned. +- `encoding` {string} Returns the Diffie-Hellman prime in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is @@ -488,6 +498,7 @@ returned; otherwise a [`Buffer`][] is returned. +- `encoding` {string} Returns the Diffie-Hellman private key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a @@ -497,6 +508,7 @@ string is returned; otherwise a [`Buffer`][] is returned. +- `encoding` {string} Returns the Diffie-Hellman public key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a @@ -506,6 +518,8 @@ string is returned; otherwise a [`Buffer`][] is returned. +- `private_key` {string | Buffer} +- `encoding` {string} Sets the Diffie-Hellman private key. If the `encoding` argument is provided and is either `'latin1'`, `'hex'`, or `'base64'`, `private_key` is expected @@ -516,6 +530,8 @@ to be a [`Buffer`][]. +- `public_key` {string | Buffer} +- `encoding` {string} Sets the Diffie-Hellman public key. If the `encoding` argument is provided and is either `'latin1'`, `'hex'` or `'base64'`, `public_key` is expected @@ -577,6 +593,9 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `other_public_key` {string | Buffer} +- `input_encoding` {string} +- `output_encoding` {string} Computes the shared secret using `other_public_key` as the other party's public key and returns the computed shared secret. The supplied @@ -592,6 +611,8 @@ If `output_encoding` is given a string will be returned; otherwise a +- `encoding` {string} +- `format` {string} Defaults to `uncompressed`. Generates private and public EC Diffie-Hellman key values, and returns the public key in the specified `format` and `encoding`. This key should be @@ -609,15 +630,18 @@ is returned. +- `encoding` {string} Returns the EC Diffie-Hellman private key in the specified `encoding`, which can be `'latin1'`, `'hex'`, or `'base64'`. If `encoding` is provided a string is returned; otherwise a [`Buffer`][] is returned. -### ecdh.getPublicKey([encoding[, format]]) +### ecdh.getPublicKey([encoding][, format]) +- `encoding` {string} +- `format` {string} Defaults to `uncompressed`. Returns the EC Diffie-Hellman public key in the specified `encoding` and `format`. @@ -634,6 +658,8 @@ returned. +- `private_key` {string | Buffer} +- `encoding` {string} Sets the EC Diffie-Hellman private key. The `encoding` can be `'latin1'`, `'hex'` or `'base64'`. If `encoding` is provided, `private_key` is expected @@ -650,6 +676,9 @@ deprecated: v5.2.0 > Stability: 0 - Deprecated +- `public_key` {string | Buffer} +- `encoding` {string} + Sets the EC Diffie-Hellman public key. Key encoding can be `'latin1'`, `'hex'` or `'base64'`. If `encoding` is provided `public_key` is expected to be a string; otherwise a [`Buffer`][] is expected. @@ -747,6 +776,7 @@ console.log(hash.digest('hex')); +- `encoding` {string} Calculates the digest of all of the data passed to be hashed (using the [`hash.update()`][] method). The `encoding` can be `'hex'`, `'latin1'` or @@ -764,6 +794,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the hash content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -834,6 +866,7 @@ console.log(hmac.digest('hex')); +- `encoding` {string} Calculates the HMAC digest of all of the data passed using [`hmac.update()`][]. The `encoding` can be `'hex'`, `'latin1'` or `'base64'`. If `encoding` is @@ -850,6 +883,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the `Hmac` content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -929,6 +964,10 @@ console.log(sign.sign(privateKey).toString('hex')); +- `private_key` {string | Object} + - `key` {string} + - `passphrase` {string} +- `output_format` {string} Calculates the signature on all the data passed through using either [`sign.update()`][] or [`sign.write()`][stream-writable-write]. @@ -955,6 +994,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the `Sign` content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -1017,6 +1058,8 @@ changes: pr-url: https://github.com/nodejs/node/pull/5522 description: The default `input_encoding` changed from `binary` to `utf8`. --> +- `data` {string | Buffer} +- `input_encoding` {string} Updates the `Verify` content with the given `data`, the encoding of which is given in `input_encoding` and can be `'utf8'`, `'ascii'` or @@ -1030,10 +1073,13 @@ This can be called many times with new data as it is streamed. +- `object` {string} +- `signature` {string | Buffer} +- `signature_format` {string} Verifies the provided data using the given `object` and `signature`. The `object` argument is a string containing a PEM encoded object, which can be -one an RSA public key, a DSA public key, or an X.509 certificate. +an RSA public key, a DSA public key, or an X.509 certificate. The `signature` argument is the previously calculated signature for the data, in the `signature_format` which can be `'latin1'`, `'hex'` or `'base64'`. If a `signature_format` is specified, the `signature` is expected to be a @@ -1084,6 +1130,8 @@ currently in use. Setting to true requires a FIPS build of Node.js. +- `algorithm` {string} +- `password` {string | Buffer} Creates and returns a `Cipher` object that uses the given `algorithm` and `password`. @@ -1108,6 +1156,9 @@ their own using [`crypto.pbkdf2()`][] and to use [`crypto.createCipheriv()`][] to create the `Cipher` object. ### crypto.createCipheriv(algorithm, key, iv) +- `algorithm` {string} +- `key` {string | Buffer} +- `iv` {string | Buffer} Creates and returns a `Cipher` object, with the given `algorithm`, `key` and initialization vector (`iv`). @@ -1142,6 +1193,8 @@ called. +- `algorithm` {string} +- `password` {string | Buffer} Creates and returns a `Decipher` object that uses the given `algorithm` and `password` (key). @@ -1162,6 +1215,9 @@ to create the `Decipher` object. +- `algorithm` {string} +- `key` {string | Buffer} +- `iv` {string | Buffer} Creates and returns a `Decipher` object that uses the given `algorithm`, `key` and initialization vector (`iv`). @@ -1183,6 +1239,10 @@ changes: description: The default for the encoding parameters changed from `binary` to `utf8`. --> +- `prime` {string | Buffer} +- `prime_encoding` {string} +- `generator` {number | string | Buffer} Defaults to `2`. +- `generator_encoding` {string} Creates a `DiffieHellman` key exchange object using the supplied `prime` and an optional specific `generator`. @@ -1203,6 +1263,8 @@ otherwise either a number or [`Buffer`][] is expected. +- `prime_length` {number} +- `generator` {number | string | Buffer} Defaults to `2`. Creates a `DiffieHellman` key exchange object and generates a prime of `prime_length` bits using an optional specific numeric `generator`. @@ -1212,6 +1274,7 @@ If `generator` is not specified, the value `2` is used. +- `curve_name` {string} Creates an Elliptic Curve Diffie-Hellman (`ECDH`) key exchange object using a predefined curve specified by the `curve_name` string. Use @@ -1223,6 +1286,7 @@ and description of each available elliptic curve. +- `algorithm` {string} Creates and returns a `Hash` object that can be used to generate hash digests using the given `algorithm`. @@ -1256,6 +1320,8 @@ input.on('readable', () => { +- `algorithm` {string} +- `key` {string | Buffer} Creates and returns an `Hmac` object that uses the given `algorithm` and `key`. @@ -1290,6 +1356,7 @@ input.on('readable', () => { +- `algorithm` {string} Creates and returns a `Sign` object that uses the given `algorithm`. Use [`crypto.getHashes()`][] to obtain an array of names of the available @@ -1299,6 +1366,7 @@ signing algorithms. +- `algorithm` {string} Creates and returns a `Verify` object that uses the given algorithm. Use [`crypto.getHashes()`][] to obtain an array of names of the available @@ -1336,6 +1404,7 @@ console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] +- `group_name` {string} Creates a predefined `DiffieHellman` key exchange object. The supported groups are: `'modp1'`, `'modp2'`, `'modp5'` (defined in @@ -1396,6 +1465,14 @@ changes: description: The default encoding for `password` if it is a string changed from `binary` to `utf8`. --> +- `password` {string} +- `salt` {string} +- `iterations` {number} +- `keylen` {number} +- `digest` {string} +- `callback` {Function} + - `err` {Error} + - `derivedKey` {Buffer} Provides an asynchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by `digest` is @@ -1418,9 +1495,9 @@ Example: ```js const crypto = require('crypto'); -crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, key) => { +crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, derivedKey) => { if (err) throw err; - console.log(key.toString('hex')); // '3745e48...aa39b34' + console.log(derivedKey.toString('hex')); // '3745e48...aa39b34' }); ``` @@ -1440,6 +1517,11 @@ changes: description: The default encoding for `password` if it is a string changed from `binary` to `utf8`. --> +- `password` {string} +- `salt` {string} +- `iterations` {number} +- `keylen` {number} +- `digest` {string} Provides a synchronous Password-Based Key Derivation Function 2 (PBKDF2) implementation. A selected HMAC digest algorithm specified by `digest` is @@ -1472,95 +1554,84 @@ An array of supported digest functions can be retrieved using +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`, + `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`. +- `buffer` {Buffer} Decrypts `buffer` with `private_key`. `private_key` can be an object or a string. If `private_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`. -If `private_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded private key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - * `crypto.constants.RSA_PKCS1_OAEP_PADDING` - -All paddings are defined in `crypto.constants`. ### crypto.privateEncrypt(private_key, buffer) +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING` or + `RSA_PKCS1_PADDING`. +- `buffer` {Buffer} Encrypts `buffer` with `private_key`. `private_key` can be an object or a string. If `private_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`. -If `private_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded private key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - -All paddings are defined in `crypto.constants`. ### crypto.publicDecrypt(public_key, buffer) +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`, + `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`. +- `buffer` {Buffer} Decrypts `buffer` with `public_key`. `public_key` can be an object or a string. If `public_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_PADDING`. -If `public_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded public key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - * `crypto.constants.RSA_PKCS1_OAEP_PADDING` Because RSA public keys can be derived from private keys, a private key may be passed instead of a public key. -All paddings are defined in `crypto.constants`. - ### crypto.publicEncrypt(public_key, buffer) +- `private_key` {Object | string} + - `key` {string} A PEM encoded private key. + - `passphrase` {string} An optional passphrase for the private key. + - `padding` {crypto.constants} An optional padding value defined in + `crypto.constants`, which may be: `crypto.constants.RSA_NO_PADDING`, + `RSA_PKCS1_PADDING`, or `crypto.constants.RSA_PKCS1_OAEP_PADDING`. +- `buffer` {Buffer} Encrypts `buffer` with `public_key`. `public_key` can be an object or a string. If `public_key` is a string, it is treated as the key with no passphrase and will use `RSA_PKCS1_OAEP_PADDING`. -If `public_key` is an object, it is interpreted as a hash object with the -keys: - -* `key`: {string} - PEM encoded public key -* `passphrase`: {string} - Optional passphrase for the private key -* `padding` : An optional padding value, one of the following: - * `crypto.constants.RSA_NO_PADDING` - * `crypto.constants.RSA_PKCS1_PADDING` - * `crypto.constants.RSA_PKCS1_OAEP_PADDING` Because RSA public keys can be derived from private keys, a private key may be passed instead of a public key. -All paddings are defined in `crypto.constants`. - ### crypto.randomBytes(size[, callback]) +- `size` {number} +- `callback` {Function} + - `err` {Error} + - `buf` {Buffer} Generates cryptographically strong pseudo-random data. The `size` argument is a number indicating the number of bytes to generate. @@ -1599,6 +1670,8 @@ time is right after boot, when the whole system is still low on entropy. +- `engine` {string} +- `flags` {crypto.constants} Defaults to `crypto.constants.ENGINE_METHOD_ALL`. Load and set the `engine` for some or all OpenSSL functions (selected by flags). @@ -1626,6 +1699,8 @@ is a bit field taking one of or a mix of the following flags (defined in +- `a` {Buffer} +- `b` {Buffer} Returns true if `a` is equal to `b`, without leaking timing information that would allow an attacker to guess one of the values. This is suitable for diff --git a/doc/api/dns.md b/doc/api/dns.md index 7f075be3114..45d494eab3b 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -70,33 +70,25 @@ changes: pr-url: https://github.com/nodejs/node/pull/744 description: The `all` option is supported now. --> +- `hostname` {string} +- `options` {integer | Object} + - `family` {integer} The record family. Must be `4` or `6`. IPv4 + and IPv6 addresses are both returned by default. + - `hints` {number} One or more [supported `getaddrinfo` flags][]. Multiple + flags may be passed by bitwise `OR`ing their values. + - `all` {boolean} When `true`, the callback returns all resolved addresses in + an array. Otherwise, returns a single address. Defaults to `false`. +- `callback` {Function} + - `err` {Error} + - `address` {string} A string representation of an IPv4 or IPv6 address. + - `family` {integer} `4` or `6`, denoting the family of `address`. Resolves a hostname (e.g. `'nodejs.org'`) into the first found A (IPv4) or -AAAA (IPv6) record. `options` can be an object or integer. If `options` is -not provided, then IPv4 and IPv6 addresses are both valid. If `options` is -an integer, then it must be `4` or `6`. - -Alternatively, `options` can be an object containing these properties: - -* `family` {number} - The record family. If present, must be the integer - `4` or `6`. If not provided, both IP v4 and v6 addresses are accepted. -* `hints`: {number} - If present, it should be one or more of the supported - `getaddrinfo` flags. If `hints` is not provided, then no flags are passed to - `getaddrinfo`. Multiple flags can be passed through `hints` by bitwise - `OR`ing their values. - See [supported `getaddrinfo` flags][] for more information on supported - flags. -* `all`: {boolean} - When `true`, the callback returns all resolved addresses - in an array, otherwise returns a single address. Defaults to `false`. - -All properties are optional. - -The `callback` function has arguments `(err, address, family)`. `address` is a -string representation of an IPv4 or IPv6 address. `family` is either the -integer `4` or `6` and denotes the family of `address` (not necessarily the -value initially passed to `lookup`). - -With the `all` option set to `true`, the arguments change to +AAAA (IPv6) record. All `option` properties are optional. If `options` is an +integer, then it must be `4` or `6` – if `options` is not provided, then IPv4 +and IPv6 addresses are both returned if found. + +With the `all` option set to `true`, the arguments for `callback` change to `(err, addresses)`, with `addresses` being an array of objects with the properties `address` and `family`. @@ -147,6 +139,12 @@ on some operating systems (e.g FreeBSD 10.1). +- `address` {string} +- `port` {number} +- `callback` {Function} + - `err` {Error} + - `hostname` {string} e.g. `example.com` + - `service` {string} e.g. `http` Resolves the given `address` and `port` into a hostname and service using the operating system's underlying `getnameinfo` implementation. @@ -155,10 +153,7 @@ If `address` is not a valid IP address, a `TypeError` will be thrown. The `port` will be coerced to a number. If it is not a legal port, a `TypeError` will be thrown. -The callback has arguments `(err, hostname, service)`. The `hostname` and -`service` arguments are strings (e.g. `'localhost'` and `'http'` respectively). - -On error, `err` is an [`Error`][] object, where `err.code` is the error code. +On an error, `err` is an [`Error`][] object, where `err.code` is the error code. ```js const dns = require('dns'); @@ -172,6 +167,11 @@ dns.lookupService('127.0.0.1', 22, (err, hostname, service) => { +- `hostname` {string} +- `rrtype` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[] | string[][] | Object} Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array of the record types specified by `rrtype`. @@ -208,18 +208,21 @@ changes: description: This method now supports passing `options`, specifically `options.ttl`. --> +- `hostname` {string} Hostname to resolve. +- `options` {Object} + - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. + When `true`, the callback receives an array of + `{ address: '1.2.3.4', ttl: 60 }` objects rather than an array of strings, + with the TTL expressed in seconds. +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[]} Uses the DNS protocol to resolve a IPv4 addresses (`A` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv4 addresses (e.g. `['74.125.79.104', '74.125.79.105', '74.125.79.106']`). -* `hostname` {string} Hostname to resolve. -* `options` {Object} - * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. - The callback receives an array of `{ address: '1.2.3.4', ttl: 60 }` objects - rather than an array of strings. The TTL is expressed in seconds. -* `callback` {Function} An `(err, result)` callback function. ## dns.resolve6(hostname[, options], callback) +- `hostname` {string} Hostname to resolve. +- `options` {Object} + - `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. + When `true`, the callback receives an array of + `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` objects rather than an array of + strings, with the TTL expressed in seconds. +- `callback` {Function} + - `err` {Error} + - `addresses` {string[] | Object[]} Uses the DNS protocol to resolve a IPv6 addresses (`AAAA` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of IPv6 addresses. -* `hostname` {string} Hostname to resolve. -* `options` {Object} - * `ttl` {boolean} Retrieve the Time-To-Live value (TTL) of each record. - The callback receives an array of `{ address: '0:1:2:3:4:5:6:7', ttl: 60 }` - objects rather than an array of strings. The TTL is expressed in seconds. -* `callback` {Function} An `(err, result)` callback function. ## dns.resolveCname(hostname, callback) +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function @@ -256,6 +266,10 @@ will contain an array of canonical name records available for the `hostname` +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve mail exchange records (`MX` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -266,11 +280,14 @@ property (e.g. `[{priority: 10, exchange: 'mx.example.com'}, ...]`). +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve regular expression based records (`NAPTR` -records) for the `hostname`. The `callback` function has arguments -`(err, addresses)`. The `addresses` argument passed to the `callback` function -will contain an array of objects with the following properties: +records) for the `hostname`. The `addresses` argument passed to the `callback` +function will contain an array of objects with the following properties: * `flags` * `service` @@ -296,16 +313,24 @@ For example: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve name server records (`NS` records) for the `hostname`. The `addresses` argument passed to the `callback` function will contain an array of name server records available for `hostname` (e.g. `['ns1.example.com', 'ns2.example.com']`). -## dns.resolvePtr(hostname, callback) +## dns.resolvePtr(hostname) +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[]} Uses the DNS protocol to resolve pointer records (`PTR` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -315,9 +340,13 @@ be an array of strings containing the reply records. +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `address` {Object} Uses the DNS protocol to resolve a start of authority record (`SOA` record) for -the `hostname`. The `addresses` argument passed to the `callback` function will +the `hostname`. The `address` argument passed to the `callback` function will be an object with the following properties: * `nsname` @@ -344,6 +373,10 @@ be an object with the following properties: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {Object[]} Uses the DNS protocol to resolve service records (`SRV` records) for the `hostname`. The `addresses` argument passed to the `callback` function will @@ -367,6 +400,10 @@ be an array of objects with the following properties: +- `hostname` {string} +- `callback` {Function} + - `err` {Error} + - `addresses` {string[][]} Uses the DNS protocol to resolve text queries (`TXT` records) for the `hostname`. The `addresses` argument passed to the `callback` function is @@ -379,13 +416,14 @@ treated separately. +- `ip` {string} +- `callback` {Function} + - `err` {Error} + - `hostnames` {string[]} Performs a reverse DNS query that resolves an IPv4 or IPv6 address to an array of hostnames. -The `callback` function has arguments `(err, hostnames)`, where `hostnames` -is an array of resolved hostnames for the given `ip`. - On error, `err` is an [`Error`][] object, where `err.code` is one of the [DNS error codes][]. @@ -393,11 +431,12 @@ one of the [DNS error codes][]. +- `servers` {string[]} Sets the IP addresses of the servers to be used when resolving. The `servers` argument is an array of IPv4 or IPv6 addresses. -If a port specified on the address it will be removed. +If a port is specified on the address, it will be removed. An error will be thrown if an invalid address is provided. diff --git a/doc/api/events.md b/doc/api/events.md index 5f12cfe3191..5c0614b68bf 100644 --- a/doc/api/events.md +++ b/doc/api/events.md @@ -98,7 +98,7 @@ listener will be invoked _every time_ the named event is emitted. ```js const myEmitter = new MyEmitter(); -var m = 0; +let m = 0; myEmitter.on('event', () => { console.log(++m); }); @@ -114,7 +114,7 @@ the listener is unregistered and *then* called. ```js const myEmitter = new MyEmitter(); -var m = 0; +let m = 0; myEmitter.once('event', () => { console.log(++m); }); @@ -148,7 +148,7 @@ can be used. (_Note, however, that the `domain` module has been deprecated_) const myEmitter = new MyEmitter(); process.on('uncaughtException', (err) => { - console.log('whoops! there was an error'); + console.error('whoops! there was an error'); }); myEmitter.emit('error', new Error('whoops!')); @@ -160,7 +160,7 @@ As a best practice, listeners should always be added for the `'error'` events. ```js const myEmitter = new MyEmitter(); myEmitter.on('error', (err) => { - console.log('whoops! there was an error'); + console.error('whoops! there was an error'); }); myEmitter.emit('error', new Error('whoops!')); // Prints: whoops! there was an error @@ -185,7 +185,7 @@ added and `'removeListener'` when existing listeners are removed. added: v0.1.26 --> -* `eventName` {string|symbol} The name of the event being listened for +* `eventName` {any} The name of the event being listened for * `listener` {Function} The event handler function The `EventEmitter` instance will emit its own `'newListener'` event *before* @@ -229,7 +229,7 @@ changes: now yields the original listener function. --> -* `eventName` {string|symbol} The event name +* `eventName` {any} The event name * `listener` {Function} The event handler function The `'removeListener'` event is emitted *after* the `listener` is removed. @@ -296,6 +296,8 @@ Its `name` property is set to `'MaxListenersExceededWarning'`. +- `eventName` {any} +- `listener` {Function} Alias for `emitter.on(eventName, listener)`. @@ -303,6 +305,8 @@ Alias for `emitter.on(eventName, listener)`. +- `eventName` {any} +- `...args` {any} Synchronously calls each of the listeners registered for the event named `eventName`, in the order they were registered, passing the supplied arguments @@ -345,7 +349,7 @@ set by [`emitter.setMaxListeners(n)`][] or defaults to added: v3.2.0 --> -* `eventName` {string|symbol} The name of the event being listened for +* `eventName` {any} The name of the event being listened for Returns the number of listeners listening to the event named `eventName`. @@ -358,6 +362,7 @@ changes: description: For listeners attached using `.once()` this returns the original listeners instead of wrapper functions now. --> +- `eventName` {any} Returns a copy of the array of listeners for the event named `eventName`. @@ -374,7 +379,7 @@ console.log(util.inspect(server.listeners('connection'))); added: v0.1.101 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds the `listener` function to the end of the listeners array for the @@ -410,7 +415,7 @@ myEE.emit('foo'); added: v0.3.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds a **one time** `listener` function for the event named `eventName`. The @@ -443,7 +448,7 @@ myEE.emit('foo'); added: v6.0.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds the `listener` function to the *beginning* of the listeners array for the @@ -465,7 +470,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. added: v6.0.0 --> -* `eventName` {string|symbol} The name of the event. +* `eventName` {any} The name of the event. * `listener` {Function} The callback function Adds a **one time** `listener` function for the event named `eventName` to the @@ -484,6 +489,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `eventName` {any} Removes all listeners, or those of the specified `eventName`. @@ -497,12 +503,14 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `eventName` {any} +- `listener` {Function} Removes the specified `listener` from the listener array for the event named `eventName`. ```js -var callback = (stream) => { +const callback = (stream) => { console.log('someone connected!'); }; server.on('connection', callback); @@ -524,12 +532,12 @@ events will behave as expected. ```js const myEmitter = new MyEmitter(); -var callbackA = () => { +const callbackA = () => { console.log('A'); myEmitter.removeListener('event', callbackB); }; -var callbackB = () => { +const callbackB = () => { console.log('B'); }; @@ -564,6 +572,7 @@ Returns a reference to the `EventEmitter`, so that calls can be chained. +- `n` {integer} By default EventEmitters will print a warning if more than `10` listeners are added for a particular event. This is a useful default that helps finding diff --git a/doc/api/net.md b/doc/api/net.md index d20e6bf767e..f1df6911859 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -40,7 +40,7 @@ double-backslashes, such as: ```js net.createServer().listen( - path.join('\\\\?\\pipe', process.cwd(), 'myctl')) + path.join('\\\\?\\pipe', process.cwd(), 'myctl')); ``` ## Class: net.Server @@ -107,7 +107,7 @@ Returns an object with `port`, `family`, and `address` properties: Example: ```js -var server = net.createServer((socket) => { +const server = net.createServer((socket) => { socket.end('goodbye\n'); }).on('error', (err) => { // handle errors here @@ -758,7 +758,7 @@ socket.setTimeout(3000); socket.on('timeout', () => { console.log('socket timeout'); socket.end(); -}) +}); ``` If `timeout` is 0, then the existing idle timeout is disabled. @@ -997,8 +997,8 @@ server.listen(8124, () => { Test this by using `telnet`: -```sh -telnet localhost 8124 +```console +$ telnet localhost 8124 ``` To listen on the socket `/tmp/echo.sock` the third line from the last would @@ -1012,8 +1012,8 @@ server.listen('/tmp/echo.sock', () => { Use `nc` to connect to a UNIX domain socket server: -```js -nc -U /tmp/echo.sock +```console +$ nc -U /tmp/echo.sock ``` ## net.isIP(input) diff --git a/doc/api/process.md b/doc/api/process.md index 0ff80980f9c..2e9b655f28c 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -298,7 +298,7 @@ too many listeners have been added to an event ```txt $ node -> event.defaultMaxListeners = 1; +> events.defaultMaxListeners = 1; > process.on('foo', () => {}); > process.on('foo', () => {}); > (node:38638) Warning: Possible EventEmitter memory leak detected. 2 foo @@ -311,7 +311,7 @@ adds a custom handler to the `'warning'` event: ```txt $ node --no-warnings > var p = process.on('warning', (warning) => console.warn('Do not do that!')); -> event.defaultMaxListeners = 1; +> events.defaultMaxListeners = 1; > process.on('foo', () => {}); > process.on('foo', () => {}); > Do not do that! diff --git a/doc/api/stream.md b/doc/api/stream.md index c48dfe05080..75cba6fd514 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1016,7 +1016,7 @@ function parseHeader(stream, callback) { const remaining = split.join('\n\n'); const buf = Buffer.from(remaining, 'utf8'); stream.removeListener('error', callback); - // set the readable listener before unshifting + // remove the readable listener before unshifting stream.removeListener('readable', onReadable); if (buf.length) stream.unshift(buf); diff --git a/doc/changelogs/CHANGELOG_V7.md b/doc/changelogs/CHANGELOG_V7.md index 53c6b345ba4..45dda5d2edd 100644 --- a/doc/changelogs/CHANGELOG_V7.md +++ b/doc/changelogs/CHANGELOG_V7.md @@ -6,6 +6,8 @@ +7.7.3
+7.7.2
7.7.1
7.7.0
7.6.0
@@ -29,6 +31,45 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2017-03-14, Version 7.7.3 (Current), @italoacasas + +### Notable changes + +* **module**: The [module loading global fallback](https://nodejs.org/dist/latest-v6.x/docs/api/modules.html#modules_loading_from_the_global_folders) to the Node executable's directory now works correctly on Windows. (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) +* **net**: `Socket.prototype.connect` now once again functions without a callback. (Juwan Yoo) [#11762](https://github.com/nodejs/node/pull/11762) +* **url**: `URL.prototype.origin` now properly specified an opaque return of `'null'` for `file://` URLs. (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) + +### Commits + +* [[`542a3735a7`](https://github.com/nodejs/node/commit/542a3735a7)] - **build**: add node_use_openssl check to install.py (Daniel Bevenius) [#11766](https://github.com/nodejs/node/pull/11766) +* [[`2fcefeeda0`](https://github.com/nodejs/node/commit/2fcefeeda0)] - **dgram**: refactor dgram to module.exports (Claudio Rodriguez) [#11696](https://github.com/nodejs/node/pull/11696) +* [[`dd3e6adaa7`](https://github.com/nodejs/node/commit/dd3e6adaa7)] - **doc**: add missing changelog heading for 7.7.2 (Evan Lucas) [#11823](https://github.com/nodejs/node/pull/11823) +* [[`b543fd441c`](https://github.com/nodejs/node/commit/b543fd441c)] - **doc**: update to current V8 versions (Franziska Hinkelmann) [#11787](https://github.com/nodejs/node/pull/11787) +* [[`6cc7b30c62`](https://github.com/nodejs/node/commit/6cc7b30c62)] - **doc**: improve child_process `maxBuffer` text (Rich Trott) [#11791](https://github.com/nodejs/node/pull/11791) +* [[`188cbc6eea`](https://github.com/nodejs/node/commit/188cbc6eea)] - **doc**: package main can be directory with an index (Bradley Farias) [#11581](https://github.com/nodejs/node/pull/11581) +* [[`a20aa0ee48`](https://github.com/nodejs/node/commit/a20aa0ee48)] - **doc**: http cleanup and missing argument types (Amelia Clarke) [#11681](https://github.com/nodejs/node/pull/11681) +* [[`8a1b2b4417`](https://github.com/nodejs/node/commit/8a1b2b4417)] - **doc**: reduce font size on smaller screens (Gibson Fahnestock) [#11695](https://github.com/nodejs/node/pull/11695) +* [[`5bea8b42d9`](https://github.com/nodejs/node/commit/5bea8b42d9)] - **doc**: fix occurences of "the the" (Jeroen Mandersloot) [#11711](https://github.com/nodejs/node/pull/11711) +* [[`517c3af21a`](https://github.com/nodejs/node/commit/517c3af21a)] - **doc**: fix process links to console.log/error (Sam Roberts) [#11718](https://github.com/nodejs/node/pull/11718) +* [[`108449b6ff`](https://github.com/nodejs/node/commit/108449b6ff)] - **doc**: add Franziska Hinkelmann to the CTC (Rod Vagg) [#11488](https://github.com/nodejs/node/pull/11488) +* [[`9c3cf13cbc`](https://github.com/nodejs/node/commit/9c3cf13cbc)] - **doc**: argument types for https methods (Amelia Clarke) [#11681](https://github.com/nodejs/node/pull/11681) +* [[`103458772a`](https://github.com/nodejs/node/commit/103458772a)] - **module**: fix loading from global folders on Windows (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) +* [[`1dff218cd1`](https://github.com/nodejs/node/commit/1dff218cd1)] - **net**: allow missing callback for Socket.connect (Juwan Yoo) [#11762](https://github.com/nodejs/node/pull/11762) +* [[`52f0092f54`](https://github.com/nodejs/node/commit/52f0092f54)] - **s390**: enable march=z196 (Junliang Yan) [#11730](https://github.com/nodejs/node/pull/11730) +* [[`032becdc28`](https://github.com/nodejs/node/commit/032becdc28)] - **src**: add missing #include \ (Steven R. Loomis) [#11754](https://github.com/nodejs/node/issues/11754) +* [[`1da2afcc26`](https://github.com/nodejs/node/commit/1da2afcc26)] - **src**: drop the NODE_ISOLATE_SLOT macro (Anna Henningsen) [#11692](https://github.com/nodejs/node/pull/11692) +* [[`734ddbe77b`](https://github.com/nodejs/node/commit/734ddbe77b)] - **test**: fix flaky test-http-set-timeout-server (Santiago Gimeno) [#11790](https://github.com/nodejs/node/pull/11790) +* [[`aaf8536dbc`](https://github.com/nodejs/node/commit/aaf8536dbc)] - **test**: add test for loading from global folders (Richard Lau) [#9283](https://github.com/nodejs/node/pull/9283) +* [[`c01c7a490a`](https://github.com/nodejs/node/commit/c01c7a490a)] - **test**: add script to create 0-dns-cert.pem (Shigeki Ohtsu) [#11579](https://github.com/nodejs/node/pull/11579) +* [[`4477e15217`](https://github.com/nodejs/node/commit/4477e15217)] - **test**: add regex in test_cyclic_link_protection (Clarence Dimitri CHARLES) [#11622](https://github.com/nodejs/node/pull/11622) +* [[`3d55cf06b1`](https://github.com/nodejs/node/commit/3d55cf06b1)] - **test**: add more WHATWG URL origin tests (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) +* [[`a98d963082`](https://github.com/nodejs/node/commit/a98d963082)] - **test**: increase coverage of console (DavidCai) [#11653](https://github.com/nodejs/node/pull/11653) +* [[`1af0fa4b84`](https://github.com/nodejs/node/commit/1af0fa4b84)] - **test**: test buffer behavior when zeroFill undefined (Rich Trott) [#11706](https://github.com/nodejs/node/pull/11706) +* [[`1e52ba3b3d`](https://github.com/nodejs/node/commit/1e52ba3b3d)] - **test**: limit lint rule disabling in message test (Rich Trott) [#11724](https://github.com/nodejs/node/pull/11724) +* [[`5e7baa5a72`](https://github.com/nodejs/node/commit/5e7baa5a72)] - **tools**: add links to the stability index reference (Michael Cox) [#11664](https://github.com/nodejs/node/pull/11664) +* [[`c5874d1bd4`](https://github.com/nodejs/node/commit/c5874d1bd4)] - **url**: remove invalid file protocol check (Brian White) [#11691](https://github.com/nodejs/node/pull/11691) + ## 2017-03-08, Version 7.7.2 (Current), @evanlucas diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md index 4bfed3790f5..e57b73bcf91 100644 --- a/doc/guides/maintaining-V8.md +++ b/doc/guides/maintaining-V8.md @@ -93,11 +93,11 @@ includes the following branches1: 2017-04-01 - 5.4 + 5.5 - 2016-10-18 + 2016-12-06 - ~2016-12-01 + 2017-01-24 @@ -107,11 +107,11 @@ includes the following branches1: N/A - 5.4 + 5.6 - 2016-10-18 + 2017-01-31 - ~2016-12-01 + 2017-03-07 diff --git a/lib/internal/net.js b/lib/internal/net.js index 8f279cad160..ce8f549bdfa 100644 --- a/lib/internal/net.js +++ b/lib/internal/net.js @@ -9,13 +9,6 @@ function isLegalPort(port) { return +port === (+port >>> 0) && port <= 0xFFFF; } - -function assertPort(port) { - if (typeof port !== 'undefined' && !isLegalPort(port)) - throw new RangeError('"port" argument must be >= 0 and < 65536'); -} - module.exports = { - isLegalPort, - assertPort + isLegalPort }; diff --git a/lib/internal/url.js b/lib/internal/url.js index 4af9e34f91b..005f5b66476 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1,7 +1,7 @@ 'use strict'; const util = require('util'); -const { StorageObject } = require('internal/querystring'); +const { hexTable, StorageObject } = require('internal/querystring'); const binding = process.binding('url'); const context = Symbol('context'); const cannotBeBase = Symbol('cannot-be-base'); @@ -597,18 +597,99 @@ function getParamsFromObject(obj) { return values; } -function getObjectFromParams(array) { - const obj = new StorageObject(); - for (var i = 0; i < array.length; i += 2) { - const name = array[i]; - const value = array[i + 1]; - if (obj[name]) { - obj[name].push(value); - } else { - obj[name] = [value]; +// Adapted from querystring's implementation. +// Ref: https://url.spec.whatwg.org/#concept-urlencoded-byte-serializer +const noEscape = [ +//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00 - 0x0F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x10 - 0x1F + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, // 0x20 - 0x2F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 0x30 - 0x3F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 0x4F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 0x50 - 0x5F + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 0x6F + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 0x70 - 0x7F +]; + +// Special version of hexTable that uses `+` for U+0020 SPACE. +const paramHexTable = hexTable.slice(); +paramHexTable[0x20] = '+'; + +function escapeParam(str) { + const len = str.length; + if (len === 0) + return ''; + + var out = ''; + var lastPos = 0; + + for (var i = 0; i < len; i++) { + var c = str.charCodeAt(i); + + // ASCII + if (c < 0x80) { + if (noEscape[c] === 1) + continue; + if (lastPos < i) + out += str.slice(lastPos, i); + lastPos = i + 1; + out += paramHexTable[c]; + continue; + } + + if (lastPos < i) + out += str.slice(lastPos, i); + + // Multi-byte characters ... + if (c < 0x800) { + lastPos = i + 1; + out += paramHexTable[0xC0 | (c >> 6)] + + paramHexTable[0x80 | (c & 0x3F)]; + continue; + } + if (c < 0xD800 || c >= 0xE000) { + lastPos = i + 1; + out += paramHexTable[0xE0 | (c >> 12)] + + paramHexTable[0x80 | ((c >> 6) & 0x3F)] + + paramHexTable[0x80 | (c & 0x3F)]; + continue; } + // Surrogate pair + ++i; + var c2; + if (i < len) + c2 = str.charCodeAt(i) & 0x3FF; + else { + // This branch should never happen because all URLSearchParams entries + // should already be converted to USVString. But, included for + // completion's sake anyway. + c2 = 0; + } + lastPos = i + 1; + c = 0x10000 + (((c & 0x3FF) << 10) | c2); + out += paramHexTable[0xF0 | (c >> 18)] + + paramHexTable[0x80 | ((c >> 12) & 0x3F)] + + paramHexTable[0x80 | ((c >> 6) & 0x3F)] + + paramHexTable[0x80 | (c & 0x3F)]; } - return obj; + if (lastPos === 0) + return str; + if (lastPos < len) + return out + str.slice(lastPos); + return out; +} + +// application/x-www-form-urlencoded serializer +// Ref: https://url.spec.whatwg.org/#concept-urlencoded-serializer +function serializeParams(array) { + const len = array.length; + if (len === 0) + return ''; + + var output = `${escapeParam(array[0])}=${escapeParam(array[1])}`; + for (var i = 2; i < len; i += 2) + output += `&${escapeParam(array[i])}=${escapeParam(array[i + 1])}`; + return output; } // Mainly to mitigate func-name-matching ESLint rule @@ -993,7 +1074,7 @@ defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', { throw new TypeError('Value of `this` is not a URLSearchParams'); } - return querystring.stringify(getObjectFromParams(this[searchParams])); + return serializeParams(this[searchParams]); } }); diff --git a/lib/repl.js b/lib/repl.js index e457dcfd2dd..2d833c96958 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -99,105 +99,6 @@ exports.writer = util.inspect; exports._builtinLibs = internalModule.builtinLibs; -class LineParser { - - constructor() { - this.reset(); - } - - reset() { - this._literal = null; - this.shouldFail = false; - this.blockComment = false; - this.regExpLiteral = false; - this.prevTokenChar = null; - } - - parseLine(line) { - var previous = null; - this.shouldFail = false; - const wasWithinStrLiteral = this._literal !== null; - - for (const current of line) { - if (previous === '\\') { - // valid escaping, skip processing. previous doesn't matter anymore - previous = null; - continue; - } - - if (!this._literal) { - if (this.regExpLiteral && current === '/') { - this.regExpLiteral = false; - previous = null; - continue; - } - if (previous === '*' && current === '/') { - if (this.blockComment) { - this.blockComment = false; - previous = null; - continue; - } else { - this.shouldFail = true; - break; - } - } - - // ignore rest of the line if `current` and `previous` are `/`s - if (previous === current && previous === '/' && !this.blockComment) { - break; - } - - if (previous === '/') { - if (current === '*') { - this.blockComment = true; - } else if ( - // Distinguish between a division operator and the start of a regex - // by examining the non-whitespace character that precedes the / - [null, '(', '[', '{', '}', ';'].includes(this.prevTokenChar) - ) { - this.regExpLiteral = true; - } - previous = null; - } - } - - if (this.blockComment || this.regExpLiteral) continue; - - if (current === this._literal) { - this._literal = null; - } else if (current === '\'' || current === '"') { - this._literal = this._literal || current; - } - - if (current.trim() && current !== '/') this.prevTokenChar = current; - - previous = current; - } - - const isWithinStrLiteral = this._literal !== null; - - if (!wasWithinStrLiteral && !isWithinStrLiteral) { - // Current line has nothing to do with String literals, trim both ends - line = line.trim(); - } else if (wasWithinStrLiteral && !isWithinStrLiteral) { - // was part of a string literal, but it is over now, trim only the end - line = line.trimRight(); - } else if (isWithinStrLiteral && !wasWithinStrLiteral) { - // was not part of a string literal, but it is now, trim only the start - line = line.trimLeft(); - } - - const lastChar = line.charAt(line.length - 1); - - this.shouldFail = this.shouldFail || - ((!this._literal && lastChar === '\\') || - (this._literal && lastChar !== '\\')); - - return line; - } -} - - function REPLServer(prompt, stream, eval_, @@ -249,8 +150,6 @@ function REPLServer(prompt, self.breakEvalOnSigint = !!breakEvalOnSigint; self.editorMode = false; - self._inTemplateLiteral = false; - // just for backwards compat, see github.com/joyent/node/pull/7127 self.rli = this; @@ -262,29 +161,20 @@ function REPLServer(prompt, eval_ = eval_ || defaultEval; - function preprocess(code) { - let cmd = code; - if (/^\s*\{/.test(cmd) && /\}\s*$/.test(cmd)) { + function defaultEval(code, context, file, cb) { + var err, result, script, wrappedErr; + var wrappedCmd = false; + var input = code; + + if (/^\s*\{/.test(code) && /\}\s*$/.test(code)) { // It's confusing for `{ a : 1 }` to be interpreted as a block // statement rather than an object literal. So, we first try // to wrap it in parentheses, so that it will be interpreted as // an expression. - cmd = `(${cmd})`; - self.wrappedCmd = true; + code = `(${code.trim()})\n`; + wrappedCmd = true; } - // Append a \n so that it will be either - // terminated, or continued onto the next expression if it's an - // unexpected end of input. - return `${cmd}\n`; - } - function defaultEval(code, context, file, cb) { - // Remove trailing new line - code = code.replace(/\n$/, ''); - code = preprocess(code); - - var input = code; - var err, result, wrappedErr; // first, create the Script object to check the syntax if (code === '\n') @@ -298,22 +188,22 @@ function REPLServer(prompt, // value for statements and declarations that don't return a value. code = `'use strict'; void 0;\n${code}`; } - var script = vm.createScript(code, { + script = vm.createScript(code, { filename: file, displayErrors: true }); } catch (e) { debug('parse error %j', code, e); - if (self.wrappedCmd) { - self.wrappedCmd = false; + if (wrappedCmd) { + wrappedCmd = false; // unwrap and try again - code = `${input.substring(1, input.length - 2)}\n`; + code = input; wrappedErr = e; continue; } // preserve original error for wrapped command const error = wrappedErr || e; - if (isRecoverableError(error, self)) + if (isRecoverableError(error, code)) err = new Recoverable(error); else err = error; @@ -400,7 +290,6 @@ function REPLServer(prompt, (_, pre, line) => pre + (line - 1)); } top.outputStream.write((e.stack || e) + '\n'); - top.lineParser.reset(); top.bufferedCommand = ''; top.lines.level = []; top.displayPrompt(); @@ -427,7 +316,6 @@ function REPLServer(prompt, self.outputStream = output; self.resetContext(); - self.lineParser = new LineParser(); self.bufferedCommand = ''; self.lines.level = []; @@ -490,7 +378,6 @@ function REPLServer(prompt, sawSIGINT = false; } - self.lineParser.reset(); self.bufferedCommand = ''; self.lines.level = []; self.displayPrompt(); @@ -498,6 +385,7 @@ function REPLServer(prompt, self.on('line', function onLine(cmd) { debug('line %j', cmd); + cmd = cmd || ''; sawSIGINT = false; if (self.editorMode) { @@ -515,23 +403,28 @@ function REPLServer(prompt, return; } - // leading whitespaces in template literals should not be trimmed. - if (self._inTemplateLiteral) { - self._inTemplateLiteral = false; - } else { - cmd = self.lineParser.parseLine(cmd); - } + // Check REPL keywords and empty lines against a trimmed line input. + const trimmedCmd = cmd.trim(); // Check to see if a REPL keyword was used. If it returns true, // display next prompt and return. - if (cmd && cmd.charAt(0) === '.' && isNaN(parseFloat(cmd))) { - var matches = cmd.match(/^\.([^\s]+)\s*(.*)$/); - var keyword = matches && matches[1]; - var rest = matches && matches[2]; - if (self.parseREPLKeyword(keyword, rest) === true) { - return; - } else if (!self.bufferedCommand) { - self.outputStream.write('Invalid REPL keyword\n'); + if (trimmedCmd) { + if (trimmedCmd.charAt(0) === '.' && isNaN(parseFloat(trimmedCmd))) { + const matches = trimmedCmd.match(/^\.([^\s]+)\s*(.*)$/); + const keyword = matches && matches[1]; + const rest = matches && matches[2]; + if (self.parseREPLKeyword(keyword, rest) === true) { + return; + } + if (!self.bufferedCommand) { + self.outputStream.write('Invalid REPL keyword\n'); + finish(null); + return; + } + } + } else { + // Print a new line when hitting enter. + if (!self.bufferedCommand) { finish(null); return; } @@ -546,12 +439,10 @@ function REPLServer(prompt, debug('finish', e, ret); self.memory(cmd); - self.wrappedCmd = false; if (e && !self.bufferedCommand && cmd.trim().startsWith('npm ')) { self.outputStream.write('npm should be run outside of the ' + 'node repl, in your normal shell.\n' + '(Press Control-D to exit.)\n'); - self.lineParser.reset(); self.bufferedCommand = ''; self.displayPrompt(); return; @@ -559,8 +450,7 @@ function REPLServer(prompt, // If error was SyntaxError and not JSON.parse error if (e) { - if (e instanceof Recoverable && !self.lineParser.shouldFail && - !sawCtrlD) { + if (e instanceof Recoverable && !sawCtrlD) { // Start buffering data like that: // { // ... x: 1 @@ -574,7 +464,6 @@ function REPLServer(prompt, } // Clear buffer if no SyntaxErrors - self.lineParser.reset(); self.bufferedCommand = ''; sawCtrlD = false; @@ -1234,7 +1123,6 @@ function defineDefaultCommands(repl) { repl.defineCommand('break', { help: 'Sometimes you get stuck, this gets you out', action: function() { - this.lineParser.reset(); this.bufferedCommand = ''; this.displayPrompt(); } @@ -1249,7 +1137,6 @@ function defineDefaultCommands(repl) { repl.defineCommand('clear', { help: clearMessage, action: function() { - this.lineParser.reset(); this.bufferedCommand = ''; if (!this.useGlobal) { this.outputStream.write('Clearing context...\n'); @@ -1370,54 +1257,117 @@ REPLServer.prototype.convertToContext = util.deprecate(function(cmd) { return cmd; }, 'replServer.convertToContext() is deprecated', 'DEP0024'); -function bailOnIllegalToken(parser) { - return parser._literal === null && - !parser.blockComment && - !parser.regExpLiteral; -} var isIncompleteSyntaxErrorMessage = (function() { if (process.jsEngine === 'v8') { - return function(message, self) { + return function(message, code) { if (message.startsWith('Unexpected end of input') || message.startsWith('missing ) after argument list') || message.startsWith('Unexpected token')) return true; if (message === 'Invalid or unexpected token') { - return !bailOnIllegalToken(self.lineParser); + return isCodeRecoverable(code); } return false; }; } else if (process.jsEngine.match(/^chakra/)) { - return function(message, self) { + return function(message, code) { if (/^(Expected|Unterminated)/.test(message) && !/ in regular expression$/.test(message)) { return true; } if (message === 'Invalid or unexpected token') { - return !bailOnIllegalToken(self.lineParser); + return isCodeRecoverable(code); } return false; }; } })(); - // If the error is that we've unexpectedly ended the input, // then let the user try to recover by adding more input. -function isRecoverableError(e, self) { +function isRecoverableError(e, code) { if (e && e.name === 'SyntaxError') { var message = e.message; if (message === 'Unterminated template literal' || message === 'Missing } in template expression') { - self._inTemplateLiteral = true; return true; } - return isIncompleteSyntaxErrorMessage(message, self); + return isIncompleteSyntaxErrorMessage(message, code); } return false; } +// Check whether a code snippet should be forced to fail in the REPL. +function isCodeRecoverable(code) { + var current, previous, stringLiteral; + var isBlockComment = false; + var isSingleComment = false; + var isRegExpLiteral = false; + var lastChar = code.charAt(code.length - 2); + var prevTokenChar = null; + + for (var i = 0; i < code.length; i++) { + previous = current; + current = code[i]; + + if (previous === '\\' && (stringLiteral || isRegExpLiteral)) { + current = null; + continue; + } + + if (stringLiteral) { + if (stringLiteral === current) { + stringLiteral = null; + } + continue; + } else { + if (isRegExpLiteral && current === '/') { + isRegExpLiteral = false; + continue; + } + + if (isBlockComment && previous === '*' && current === '/') { + isBlockComment = false; + continue; + } + + if (isSingleComment && current === '\n') { + isSingleComment = false; + continue; + } + + if (isBlockComment || isRegExpLiteral || isSingleComment) continue; + + if (current === '/' && previous === '/') { + isSingleComment = true; + continue; + } + + if (previous === '/') { + if (current === '*') { + isBlockComment = true; + } else if ( + // Distinguish between a division operator and the start of a regex + // by examining the non-whitespace character that precedes the / + [null, '(', '[', '{', '}', ';'].includes(prevTokenChar) + ) { + isRegExpLiteral = true; + } + continue; + } + + if (current.trim()) prevTokenChar = current; + } + + if (current === '\'' || current === '"') { + stringLiteral = current; + } + } + + return stringLiteral ? lastChar === '\\' : isBlockComment; +} + function Recoverable(err) { this.err = err; } diff --git a/test/fixtures/url-tests.js b/test/fixtures/url-tests.js index 0e510eb366d..a4e7de9f26b 100644 --- a/test/fixtures/url-tests.js +++ b/test/fixtures/url-tests.js @@ -4639,7 +4639,7 @@ module.exports = "port": "", "pathname": "/foo/bar", "search": "??a=b&c=d", - // "searchParams": "%3Fa=b&c=d", + "searchParams": "%3Fa=b&c=d", "hash": "" }, "# Scheme only", diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index 1dec70aca8c..42994007e83 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -20,7 +20,7 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const fork = require('child_process').fork; const net = require('net'); @@ -81,9 +81,10 @@ if (process.argv[2] === 'child') { const child = fork(process.argv[1], ['child']); - child.on('exit', function() { - console.log('CHILD: died'); - }); + child.on('exit', common.mustCall(function(code, signal) { + const message = `CHILD: died with ${code}, ${signal}`; + assert.strictEqual(code, 0, message); + })); // send net.Server to child and test by connecting const testServer = function(callback) { @@ -192,7 +193,6 @@ if (process.argv[2] === 'child') { testSocket(function() { socketSuccess = true; - child.kill(); }); }); diff --git a/test/parallel/test-child-process-fork-stdio-string-variant.js b/test/parallel/test-child-process-fork-stdio-string-variant.js index 51c943da090..5c69850216a 100644 --- a/test/parallel/test-child-process-fork-stdio-string-variant.js +++ b/test/parallel/test-child-process-fork-stdio-string-variant.js @@ -12,16 +12,19 @@ const childScript = `${common.fixturesDir}/child-process-spawn-node`; const errorRegexp = /^TypeError: Incorrect value of stdio option:/; const malFormedOpts = {stdio: '33'}; const payload = {hello: 'world'}; -const stringOpts = {stdio: 'pipe'}; assert.throws(() => fork(childScript, malFormedOpts), errorRegexp); -const child = fork(childScript, stringOpts); +function test(stringVariant) { + const child = fork(childScript, {stdio: stringVariant}); -child.on('message', (message) => { - assert.deepStrictEqual(message, {foo: 'bar'}); -}); + child.on('message', common.mustCall((message) => { + assert.deepStrictEqual(message, {foo: 'bar'}); + })); -child.send(payload); + child.send(payload); -child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0))); + child.on('exit', common.mustCall((code) => assert.strictEqual(code, 0))); +} + +['pipe', 'inherit', 'ignore'].forEach(test); diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js index 43b74069ac0..0420a21cb4c 100644 --- a/test/parallel/test-http-set-timeout-server.js +++ b/test/parallel/test-http-set-timeout-server.js @@ -138,10 +138,13 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { test(function serverResponseTimeoutWithPipeline(cb) { let caughtTimeout = ''; + let secReceived = false; process.on('exit', function() { assert.strictEqual(caughtTimeout, '/2'); }); const server = http.createServer(function(req, res) { + if (req.url === '/2') + secReceived = true; const s = res.setTimeout(50, function() { caughtTimeout += req.url; }); @@ -149,9 +152,11 @@ test(function serverResponseTimeoutWithPipeline(cb) { if (req.url === '/1') res.end(); }); server.on('timeout', function(socket) { - socket.destroy(); - server.close(); - cb(); + if (secReceived) { + socket.destroy(); + server.close(); + cb(); + } }); server.listen(common.mustCall(function() { const port = server.address().port; diff --git a/test/known_issues/test-repl-function-redefinition-edge-case.js b/test/parallel/test-repl-function-definition-edge-case.js similarity index 95% rename from test/known_issues/test-repl-function-redefinition-edge-case.js rename to test/parallel/test-repl-function-definition-edge-case.js index 03b721fba7e..1e3063e3db5 100644 --- a/test/known_issues/test-repl-function-redefinition-edge-case.js +++ b/test/parallel/test-repl-function-definition-edge-case.js @@ -13,7 +13,7 @@ r.input.emit('data', 'function a() { return 42; } (1)\n'); r.input.emit('data', 'a\n'); r.input.emit('data', '.exit'); -const expected = '1\n[Function a]\n'; +const expected = '1\n[Function: a]\n'; const got = r.output.accumulator.join(''); assert.strictEqual(got, expected); diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 76d55250d4f..a5f7895e1cd 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -456,7 +456,13 @@ function error_test() { { client: client_unix, send: '(function() {\nif (false) {} /bar"/;\n}())', expect: prompt_multiline + prompt_multiline + 'undefined\n' + prompt_unix - } + }, + // Newline within template string maintains whitespace. + { client: client_unix, send: '`foo \n`', + expect: prompt_multiline + '\'foo \\n\'\n' + prompt_unix }, + // Whitespace is not evaluated. + { client: client_unix, send: ' \t \n', + expect: prompt_unix } ].filter((v) => !common.engineSpecificMessage(v))); } diff --git a/test/parallel/test-url-relative.js b/test/parallel/test-url-relative.js index aff0eb76f88..cf379e591d6 100644 --- a/test/parallel/test-url-relative.js +++ b/test/parallel/test-url-relative.js @@ -368,6 +368,9 @@ const relativeTests2 = [ ['https://example.com/foo', 'https://user:password@example.com', 'https://user:password@example.com/foo'], + + // No path at all + ['#hash1', '#hash2', '#hash1'] ]; relativeTests2.forEach(function(relativeTest) { const a = url.resolve(relativeTest[1], relativeTest[0]); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index bfdc29aea81..aad201806e6 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -30,7 +30,9 @@ assert.strictEqual(util.inspect(false), 'false'); assert.strictEqual(util.inspect(''), "''"); assert.strictEqual(util.inspect('hello'), "'hello'"); assert.strictEqual(util.inspect(function() {}), '[Function]'); +assert.strictEqual(util.inspect(() => {}), '[Function]'); assert.strictEqual(util.inspect(async function() {}), '[AsyncFunction]'); +assert.strictEqual(util.inspect(async () => {}), '[AsyncFunction]'); assert.strictEqual(util.inspect(function*() {}), '[GeneratorFunction]'); assert.strictEqual(util.inspect(undefined), 'undefined'); assert.strictEqual(util.inspect(null), 'null'); @@ -55,8 +57,11 @@ assert.strictEqual(util.inspect({a: function() {}}), v8: '{ a: [Function: a] }', chakracore: '{ a: [Function: a] }' })); +assert.strictEqual(util.inspect({a: () => {}}), '{ a: [Function: a] }'); assert.strictEqual(util.inspect({a: async function() {}}), '{ a: [AsyncFunction: a] }'); +assert.strictEqual(util.inspect({a: async () => {}}), + '{ a: [AsyncFunction: a] }'); assert.strictEqual(util.inspect({a: function*() {}}), '{ a: [GeneratorFunction: a] }'); diff --git a/test/parallel/test-vm-run-in-new-context.js b/test/parallel/test-vm-run-in-new-context.js index 04bc3bf4a1e..0da73ea6a90 100644 --- a/test/parallel/test-vm-run-in-new-context.js +++ b/test/parallel/test-vm-run-in-new-context.js @@ -38,7 +38,7 @@ assert.strictEqual('passed', result); console.error('thrown error'); assert.throws(function() { vm.runInNewContext('throw new Error(\'test\');'); -}); +}, /^Error: test$/); global.hello = 5; vm.runInNewContext('hello = 2'); diff --git a/test/parallel/test-whatwg-url-constructor.js b/test/parallel/test-whatwg-url-constructor.js index c5d70b3f4c1..c2773b9af10 100644 --- a/test/parallel/test-whatwg-url-constructor.js +++ b/test/parallel/test-whatwg-url-constructor.js @@ -120,12 +120,12 @@ function runURLSearchParamTests() { // And in the other direction, altering searchParams propagates // back to 'search'. searchParams.append('i', ' j ') - // assert_equals(url.search, '?e=f&g=h&i=+j+') - // assert_equals(url.searchParams.toString(), 'e=f&g=h&i=+j+') + assert_equals(url.search, '?e=f&g=h&i=+j+') + assert_equals(url.searchParams.toString(), 'e=f&g=h&i=+j+') assert_equals(searchParams.get('i'), ' j ') searchParams.set('e', 'updated') - // assert_equals(url.search, '?e=updated&g=h&i=+j+') + assert_equals(url.search, '?e=updated&g=h&i=+j+') assert_equals(searchParams.get('e'), 'updated') var url2 = bURL('http://example.org/file??a=b&c=d') diff --git a/test/parallel/test-whatwg-url-searchparams-constructor.js b/test/parallel/test-whatwg-url-searchparams-constructor.js index 6720ae35cb2..b7bdcd2ae44 100644 --- a/test/parallel/test-whatwg-url-searchparams-constructor.js +++ b/test/parallel/test-whatwg-url-searchparams-constructor.js @@ -11,7 +11,7 @@ const { /* eslint-disable */ var params; // Strict mode fix for WPT. /* WPT Refs: - https://github.com/w3c/web-platform-tests/blob/405394a/url/urlsearchparams-constructor.html + https://github.com/w3c/web-platform-tests/blob/e94c604916/url/urlsearchparams-constructor.html License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html */ test(function() { @@ -154,7 +154,7 @@ test(function() { }, "Constructor with sequence of sequences of strings"); [ -// { "input": {"+": "%C2"}, "output": [[" ", "\uFFFD"]], "name": "object with +" }, + { "input": {"+": "%C2"}, "output": [["+", "%C2"]], "name": "object with +" }, { "input": {c: "x", a: "?"}, "output": [["c", "x"], ["a", "?"]], "name": "object with two keys" }, { "input": [["c", "x"], ["a", "?"]], "output": [["c", "x"], ["a", "?"]], "name": "array with two keys" } ].forEach((val) => { diff --git a/test/parallel/test-whatwg-url-searchparams-stringifier.js b/test/parallel/test-whatwg-url-searchparams-stringifier.js index 5f751b1c503..ac09979e027 100644 --- a/test/parallel/test-whatwg-url-searchparams-stringifier.js +++ b/test/parallel/test-whatwg-url-searchparams-stringifier.js @@ -10,14 +10,14 @@ const { test, assert_equals } = common.WPT; https://github.com/w3c/web-platform-tests/blob/8791bed/url/urlsearchparams-stringifier.html License: http://www.w3.org/Consortium/Legal/2008/04-testsuite-copyright.html */ -// test(function() { -// var params = new URLSearchParams(); -// params.append('a', 'b c'); -// assert_equals(params + '', 'a=b+c'); -// params.delete('a'); -// params.append('a b', 'c'); -// assert_equals(params + '', 'a+b=c'); -// }, 'Serialize space'); +test(function() { + var params = new URLSearchParams(); + params.append('a', 'b c'); + assert_equals(params + '', 'a=b+c'); + params.delete('a'); + params.append('a b', 'c'); + assert_equals(params + '', 'a+b=c'); +}, 'Serialize space'); test(function() { var params = new URLSearchParams(); @@ -114,8 +114,8 @@ test(function() { var params; params = new URLSearchParams('a=b&c=d&&e&&'); assert_equals(params.toString(), 'a=b&c=d&e='); - // params = new URLSearchParams('a = b &a=b&c=d%20'); - // assert_equals(params.toString(), 'a+=+b+&a=b&c=d+'); + params = new URLSearchParams('a = b &a=b&c=d%20'); + assert_equals(params.toString(), 'a+=+b+&a=b&c=d+'); // The lone '=' _does_ survive the roundtrip. params = new URLSearchParams('a=&a=b'); assert_equals(params.toString(), 'a=&a=b'); diff --git a/test/parallel/test-whatwg-url-searchparams.js b/test/parallel/test-whatwg-url-searchparams.js index e0d18265967..7d6df646407 100644 --- a/test/parallel/test-whatwg-url-searchparams.js +++ b/test/parallel/test-whatwg-url-searchparams.js @@ -7,7 +7,7 @@ const URL = require('url').URL; // Tests below are not from WPT. const serialized = 'a=a&a=1&a=true&a=undefined&a=null&a=%EF%BF%BD' + '&a=%EF%BF%BD&a=%F0%9F%98%80&a=%EF%BF%BD%EF%BF%BD' + - '&a=%5Bobject%20Object%5D'; + '&a=%5Bobject+Object%5D'; const values = ['a', 1, true, undefined, null, '\uD83D', '\uDE00', '\uD83D\uDE00', '\uDE00\uD83D', {}]; const normalizedValues = ['a', '1', 'true', 'undefined', 'null', '\uFFFD', diff --git a/tools/install.py b/tools/install.py index 394c6001fb1..6491adb89ed 100755 --- a/tools/install.py +++ b/tools/install.py @@ -165,7 +165,8 @@ def headers(action): if 'false' == variables.get('node_shared_libuv'): subdir_files('deps/uv/include', 'include/node/', action) - if 'false' == variables.get('node_shared_openssl'): + if 'true' == variables.get('node_use_openssl') and \ + 'false' == variables.get('node_shared_openssl'): subdir_files('deps/openssl/openssl/include/openssl', 'include/node/openssl/', action) subdir_files('deps/openssl/config/archs', 'include/node/openssl/archs', action) action(['deps/openssl/config/opensslconf.h'], 'include/node/openssl/')