]> git.kaiwu.me - njs.git/log
njs.git
3 years agoTests: improved shell_test portability to different environments.
Dmitry Volyntsev [Wed, 5 Apr 2023 05:19:49 +0000 (22:19 -0700)]
Tests: improved shell_test portability to different environments.

3 years agoVM: removed vm->variables_hash.
Dmitry Volyntsev [Wed, 5 Apr 2023 05:19:48 +0000 (22:19 -0700)]
VM: removed vm->variables_hash.

3 years agoVM: removed vm->global_items.
Dmitry Volyntsev [Wed, 5 Apr 2023 05:17:26 +0000 (22:17 -0700)]
VM: removed vm->global_items.

3 years agoAligned Number constructor to the spec.
Dmitry Volyntsev [Thu, 30 Mar 2023 03:28:33 +0000 (20:28 -0700)]
Aligned Number constructor to the spec.

Previously, negative hexadecimal numbers were accepted as valid,
whereas they are invalid input for the constructor.
Also previously, the constructor did not accepted positive binary or
octadecimal numbers as valid.

This closes #630 issue on Github.

3 years agoAdded "zlib" module.
Dmitry Volyntsev [Tue, 28 Mar 2023 05:41:27 +0000 (22:41 -0700)]
Added "zlib" module.

    - zlib.deflateRawSync(string|buffer, options?) compresses data using
        deflate, and do not append a zlib header, returns Buffer.
    - zlib.deflateSync(string|buffer, options?) compresses data using
        deflate, returns Buffer.
    - zlib.inflateRawSync(string|buffer) decompresses a raw deflate
        stream, returns Buffer.
    - zlib.inflateSync(string|buffer) decompresses a deflate stream,
        return Buffer.

3 years agoFix compiler detection when CC has a wrapper.
Orgad Shaneh [Wed, 22 Mar 2023 13:22:37 +0000 (15:22 +0200)]
Fix compiler detection when CC has a wrapper.

For example CC='ccache gcc'.

3 years agoFixed invalid NULL pointer check.
Vadim Zhestikov [Wed, 22 Mar 2023 16:36:58 +0000 (09:36 -0700)]
Fixed invalid NULL pointer check.

This fixes Coverity issues CID 1524495 and CID 1524494.

3 years agoCrypto: added Hash.copy() method.
Dmitry Volyntsev [Tue, 21 Mar 2023 04:25:47 +0000 (21:25 -0700)]
Crypto: added Hash.copy() method.

This closes #625 issue on Github.

3 years agoAdded support for export {name as default} statement.
Vadim Zhestikov [Tue, 21 Mar 2023 04:09:58 +0000 (21:09 -0700)]
Added support for export {name as default} statement.

This fixes #624 issue on Github.

3 years agoFetch: fixed Headers() constructor.
Dmitry Volyntsev [Fri, 10 Mar 2023 22:15:29 +0000 (14:15 -0800)]
Fetch: fixed Headers() constructor.

Previously, the 'guard' field of ngx_js_headers_t structure was uninitialized,
that caused spurious exception "Error: cannot append to immutable object".

This issue was introduced on 0.7.10.

3 years agoVersion bump.
Dmitry Volyntsev [Fri, 10 Mar 2023 21:28:21 +0000 (13:28 -0800)]
Version bump.

3 years agoAdded tag 0.7.11 for changeset 26dd3824b9f3
Dmitry Volyntsev [Thu, 9 Mar 2023 21:21:48 +0000 (13:21 -0800)]
Added tag 0.7.11 for changeset 26dd3824b9f3

3 years agoVersion 0.7.11. 0.7.11
Dmitry Volyntsev [Thu, 9 Mar 2023 17:26:03 +0000 (09:26 -0800)]
Version 0.7.11.

3 years agoFixed String.prototype.replace() with replacement containing "$'", "$`".
Dmitry Volyntsev [Wed, 8 Mar 2023 04:51:45 +0000 (20:51 -0800)]
Fixed String.prototype.replace() with replacement containing "$'", "$`".

Previously, the resulting string was might be broken when the string to
replace and the search string were UTF-8.  pos is always a character
offset, it should not be directly used as a byte size or offset.

3 years agoMaking njs_string_prop() a macro.
Dmitry Volyntsev [Wed, 8 Mar 2023 04:38:08 +0000 (20:38 -0800)]
Making njs_string_prop() a macro.

3 years agoIntroduced njs_string_offset() which support any string.
Dmitry Volyntsev [Wed, 8 Mar 2023 04:35:00 +0000 (20:35 -0800)]
Introduced njs_string_offset() which support any string.

3 years agoImproved njs_string_create_chb().
Dmitry Volyntsev [Sat, 4 Mar 2023 02:50:23 +0000 (18:50 -0800)]
Improved njs_string_create_chb().

Adding a more informative description when the function cannot build a
valid UTF-8 string out of chained buffers.

3 years agoFixed njs_string_to_number() with additional space symbols.
Artem S. Povalyukhin [Fri, 3 Mar 2023 19:57:30 +0000 (22:57 +0300)]
Fixed njs_string_to_number() with additional space symbols.

This closes #621 issue on Github.

3 years agoFixed Array.prototype.sort() when array is changed while sorting.
Dmitry Volyntsev [Sat, 4 Mar 2023 01:49:11 +0000 (17:49 -0800)]
Fixed Array.prototype.sort() when array is changed while sorting.

Previously, the fast-path check did not take into account the fact that
the flat array may be resized as a side effect of the array's values
evaluation.

In addition, the slow_path fix ensures that "this" array is repopulated
again even if the array was resized.

This fixes #594 issue on Github.

3 years agoFetch: fixed typo in debug level.
Dmitry Volyntsev [Sat, 4 Mar 2023 01:49:10 +0000 (17:49 -0800)]
Fetch: fixed typo in debug level.

3 years agoXML: removed XML_PARSE_DTDVALID during a document parsing.
Dmitry Volyntsev [Thu, 2 Mar 2023 05:38:09 +0000 (21:38 -0800)]
XML: removed XML_PARSE_DTDVALID during a document parsing.

When XML_PARSE_DTDVALID is enabled libxml2 parses and executes external
entities present inside an xml document.  This can lead to all the
classic XXE exploits, including SSRF and local file disclosure.

The issue was introduced in 99b9f83e4d4d (0.7.10).

Thanks to @BitK_.

3 years agoXML: fixed memory leaks in node.$tags set handler.
Dmitry Volyntsev [Wed, 1 Mar 2023 04:34:38 +0000 (20:34 -0800)]
XML: fixed memory leaks in node.$tags set handler.

If xmlAddChild() failed the node pointer leaked,
if xmlReconciliateNs() failed the copy pointer leaked.

3 years agoXML: fixed memory leak when exception happens in node.addChild().
Dmitry Volyntsev [Wed, 1 Mar 2023 04:34:31 +0000 (20:34 -0800)]
XML: fixed memory leak when exception happens in node.addChild().

The issue was introduced in 3891f338e2c9.

Found by Coverity (CID 1521487).

3 years agoFixed attaching of a stack to an error object.
Dmitry Volyntsev [Tue, 28 Feb 2023 08:26:45 +0000 (00:26 -0800)]
Fixed attaching of a stack to an error object.

This problem is similar to previous commits.  When
njs_error_stack_attach() accepted the value as a pointer to vm->retval
that value might be changed as a side effert of njs_error_stack_new()
evaluation.  This may result in a garbage value for
njs_object(value) expression.

The workaround fix is to make a copy of vm->retval to ensure its
intergrity and to preserve it as a retval. The proper fix is to
eliminate vm->retval altogether.

This fixes #612, #613, #616 issues on Github.

3 years agoWebCrypto: fixed compilation with --debug=YES.
Dmitry Volyntsev [Tue, 28 Feb 2023 07:55:55 +0000 (23:55 -0800)]
WebCrypto: fixed compilation with --debug=YES.

The issue was introduced in 2e3bbe8743af (0.7.10).

3 years agoFixed a func instance dumping with "name" as getter.
Dmitry Volyntsev [Tue, 28 Feb 2023 06:14:36 +0000 (22:14 -0800)]
Fixed a func instance dumping with "name" as getter.

After njs_value_property() call the value argument might be
overwritten.

This is similar to #615.

3 years agoFixed njs_object_property() with NJS_WHITEOUT properties.
Dmitry Volyntsev [Tue, 28 Feb 2023 06:14:36 +0000 (22:14 -0800)]
Fixed njs_object_property() with NJS_WHITEOUT properties.

Previosly, an error object dumping might result in invalid pointer
dereference when 'name' or 'message' property of accessor descriptor
type was added and removed before.

The fix is to properly handle NJS_WHITEOUT properties.

This fixes #617 issue on Github.

3 years agoFixed array instance with a getter property dumping.
Dmitry Volyntsev [Tue, 28 Feb 2023 06:14:36 +0000 (22:14 -0800)]
Fixed array instance with a getter property dumping.

This closes #618 issue on Github.

3 years agoFixed Error() instance dumping when "name" prop is not primitive.
Dmitry Volyntsev [Tue, 28 Feb 2023 06:14:34 +0000 (22:14 -0800)]
Fixed Error() instance dumping when "name" prop is not primitive.

Previously, njs_error_to_string2() might be invoked with error argument
pointing to vm->retval.  When "name" prop was not primitive vm->retval
might be overwritten.  As a result error pointer might be referencing a
primitive value.  In turn the second call of njs_object_property()
received an invalid object pointer because it expects only object value
types.

The fix is to ensure that error object pointer is never overwritten.

This closes #615 issue on Github.

3 years agoUnit tests: replacing njs_vm_retval_string() with njs_vm_retval_dump().
Dmitry Volyntsev [Tue, 28 Feb 2023 03:05:03 +0000 (19:05 -0800)]
Unit tests: replacing njs_vm_retval_string() with njs_vm_retval_dump().

The change allows to cover CLI behaviour more closely.

3 years agoParser: fixed the detection of await in arguments.
Vadim Zhestikov [Tue, 28 Feb 2023 02:39:44 +0000 (18:39 -0800)]
Parser: fixed the detection of await in arguments.

This fixes #619 issue on Github.

3 years agoStream: added missed linking with libxml2 for the dynamic module.
Dmitry Volyntsev [Tue, 28 Feb 2023 02:16:01 +0000 (18:16 -0800)]
Stream: added missed linking with libxml2 for the dynamic module.

The issue was introduced in 99b9f83e4d4d (0.7.10).

3 years agoXML: added XMLNode API to modify XML documents.
Dmitry Volyntsev [Thu, 23 Feb 2023 03:13:08 +0000 (19:13 -0800)]
XML: added XMLNode API to modify XML documents.

    - delete node.$attr$a is a shorthand syntax for
        node.removeAttribute('a')

    - node.removeAllAttributes() removes all attributes of the node.

    - node.removeAttribute(attr_name) removes attribute named
        attr_name.

    - node.setAttribute(attr_name, value || null) sets a value for an
    attr_name. When value is null attribute named attr_name is
    deleted.

    - node.$attr$a = 'xxx' is a shorthand syntax for
        node.setAttribute('a', 'xxx');

    - The methods and operations below make copy-on-write
        changes to the original XML parsed document.

        For example:
        var doc = xml.parse(<r><a><b/></a></r>);
        var b = doc.$root.a.b;
        doc.$root.removeAllChildren();

        console.log((new TextDecoder()).decode(xml.c14n(doc))); /* <r></r> */
        console.log(b); /* XMLNode {$name:'b'} */
        console.log(b.$parent); /* XMLNode {$name:'a',$tags:[XMLNode
                                  {$name:'b'}] */

        "b" is valid after removeAllChildren() call, but is not a part
        of the document tree anymore.

    - node.addChild(nd) adds XMLNode as a child to node.
      nd recursively copied before adding to the node.

    - node.removeChildren(tag_name?) removes all the children tags
        named tag_name. If tag_name is absent all children tags are
        removed.

    - node.removeText() removes the node's text value.

    - node.setText(string || null) sets a text value for the node.
        When value is null the node's text is deleted.

    - node.$tags = [node1, node2, ..] is a shorthand syntax for
        node.removeChildren();
        node.addChild(node1);
        node.addChild(node2)

    - node.$text = 'xxx' is a shorthand syntax for
        node.setText('xxx');

    In addition the following method were added:
    - xml.serialize() is the same as xml.c14n()

    - xml.serializeToString() is the same as xml.c14n()
        except it returns the result as string.

    Example:
        const xml = require("xml");
        let data = `<note><to b="bar" a="foo">Tove</to><from>Jani</from></note>`;
        let doc = xml.parse(data);

        doc.$root.to.$attr$b = 'bar2';
        doc.$root.to.setAttribute('c', 'baz');
        delete doc.$root.to.$attr$a;

        console.log(xml.serializeToString(doc.$root.to)) /* '<to b="bar2" c="baz">Tove</to>' */

        doc.$root.to.removeAllAttributes();
        doc.$root.from.$text = 'Jani2';

        console.log(xml.serializeToString(doc)) /* '<note><to>Tove</to><from>Jani2</from></note>' */

        doc.$root.to.$tags = [xml.parse(`<a/>`), xml.parse(`<b/>`)];
        doc.$root.to.addChild(xml.parse(`<a/>`));

        console.log(xml.serializeToString(doc.$root.to)) /* '<to><a></a><b></b><a></a></to>' */

        doc.$root.to.removeChildren('a');

        console.log(xml.serializeToString(doc.$root.to)) /* '<to><b></b></to>' */

3 years agoAdded njs_vm_value_to_c_string().
Dmitry Volyntsev [Sat, 18 Feb 2023 06:38:25 +0000 (22:38 -0800)]
Added njs_vm_value_to_c_string().

3 years agoTypes: updated Fetch API types.
Dmitry Volyntsev [Fri, 10 Feb 2023 02:34:51 +0000 (18:34 -0800)]
Types: updated Fetch API types.

3 years agoTypes: added forgotten r.rawHeadersIn and r.rawHeadersOut description.
Dmitry Volyntsev [Fri, 10 Feb 2023 02:34:51 +0000 (18:34 -0800)]
Types: added forgotten r.rawHeadersIn and r.rawHeadersOut description.

3 years agoTypes: fixed Fetch API types.
Dmitry Volyntsev [Fri, 10 Feb 2023 02:34:51 +0000 (18:34 -0800)]
Types: fixed Fetch API types.

3 years agoVersion bump.
Dmitry Volyntsev [Fri, 10 Feb 2023 02:34:46 +0000 (18:34 -0800)]
Version bump.

3 years agoAdded tag 0.7.10 for changeset 3a1b46d51f04
Dmitry Volyntsev [Tue, 7 Feb 2023 17:03:04 +0000 (09:03 -0800)]
Added tag 0.7.10 for changeset 3a1b46d51f04

3 years agoRemoved tag 0.7.10 0.7.10
Dmitry Volyntsev [Tue, 7 Feb 2023 17:02:59 +0000 (09:02 -0800)]
Removed tag 0.7.10

3 years agoAdded tag 0.7.10 for changeset 60a3ffe734b6
Dmitry Volyntsev [Mon, 6 Feb 2023 18:50:08 +0000 (10:50 -0800)]
Added tag 0.7.10 for changeset 60a3ffe734b6

3 years agoVersion 0.7.10.
Dmitry Volyntsev [Mon, 6 Feb 2023 17:57:17 +0000 (09:57 -0800)]
Version 0.7.10.

3 years agoFetch: fixed compatibility with nginx-1.22 and below.
Dmitry Volyntsev [Sat, 4 Feb 2023 06:17:53 +0000 (22:17 -0800)]
Fetch: fixed compatibility with nginx-1.22 and below.

Previously, ngx_table_elt_t structure was used directly in njs fetch
code.  This prevents from building with nginx-1.22 as the structure
was changed after nginx-1.22.

The fix is to use njs defined structure instead of ngx_table_elt_t.

This fixes #610 issue on Github.

3 years agoAdded String.prototype.replaceAll().
Vadim Zhestikov [Fri, 3 Feb 2023 14:41:01 +0000 (06:41 -0800)]
Added String.prototype.replaceAll().

3 years agoFixed RegExp.prototype[@@replace]().
Vadim Zhestikov [Thu, 2 Feb 2023 18:01:26 +0000 (10:01 -0800)]
Fixed RegExp.prototype[@@replace]().

Previously, when RegExpExec() returned a fast-array with gaps
String.prototype.replace() might return erroneous exception
TypeError: Cannot convert object to primitive value.

3 years agoProperly fixed memory leak after 948b167202b2.
Dmitry Volyntsev [Thu, 2 Feb 2023 03:06:22 +0000 (19:06 -0800)]
Properly fixed memory leak after 948b167202b2.

This prevents double-free introduced in 948b167202b2.

3 years agoTypes: added ts types for the xml API.
Dmitry Volyntsev [Thu, 2 Feb 2023 03:04:39 +0000 (19:04 -0800)]
Types: added ts types for the xml API.

3 years agoFixed memory leak when exception happens at xml.exclusiveC14n().
Dmitry Volyntsev [Tue, 31 Jan 2023 02:19:16 +0000 (18:19 -0800)]
Fixed memory leak when exception happens at xml.exclusiveC14n().

Found by Coverity (CID 1520596).

3 years agoFixed typos introduced in 99b9f83e4d4d.
Dmitry Volyntsev [Tue, 31 Jan 2023 01:43:59 +0000 (17:43 -0800)]
Fixed typos introduced in 99b9f83e4d4d.

Found by Coverity (CID 152059715205981520599).

3 years ago2023 year.
Dmitry Volyntsev [Tue, 31 Jan 2023 01:35:58 +0000 (17:35 -0800)]
2023 year.

3 years agoReport libxml2 used for build.
Konstantin Pavlov [Fri, 27 Jan 2023 23:19:38 +0000 (15:19 -0800)]
Report libxml2 used for build.

3 years agoAdded pkg-config-based libxml2 detection.
Konstantin Pavlov [Fri, 27 Jan 2023 23:10:57 +0000 (15:10 -0800)]
Added pkg-config-based libxml2 detection.

3 years agoAdded description for --no-libxml2 option.
Konstantin Pavlov [Fri, 27 Jan 2023 23:08:41 +0000 (15:08 -0800)]
Added description for --no-libxml2 option.

3 years agoAdded "xml" module for working with XML documents.
Dmitry Volyntsev [Thu, 26 Jan 2023 05:54:47 +0000 (21:54 -0800)]
Added "xml" module for working with XML documents.

    - xml.parse(string|buffer) returns an XMLDoc wrapper object around
        XML structure.
    - xml.c14n(root_node[, excluding_node]]) canonicalizes root_node and
        its children according to https://www.w3.org/TR/xml-c14n, optionally
        excluding_node allows to omit from the output a part of the
        document.
    - xml.exclusiveC14n(root_node[, excluding_node[, withComments [,
            prefix_list]]]) canonicalizes root_node and its children
        according to https://www.w3.org/TR/xml-exc-c14n/.  excluding_node
        allows to omit from the output a part of the document
        corresponding to the node and its children.  withComments
        is a boolean and is false by default. When withComments is true
        canonicalization corresponds to
        http://www.w3.org/2001/10/xml-exc-c14n#WithComments.  prefix_list is
        an optional string with a space separated namespace prefixes for
        namespaces that should also be included into the output.

    - XMLDoc an XMLDoc wrapper object around XML structure.
        doc.xxx returns the first root tag named "xxx" as XMLNode wrapper
        object.

    - XMLNode an XMLNode wrapper object around XML tag node.
        node.$tag$xxx returns the first child tag named "xxx" as XMLNode
        wrapper object.
        node.xxx a shorthand syntax for node.$tag$xxx.
        node.$tags$xxx? returns an array of all children tags named xxx.

        node.$attr$xxx returns an attribute value of xxx.
        node.$attrs returns an XMLAttr wrapper object.
        node.$name returns the tag name of the node.
        node.$ns returns the namespace of the node.
        node.$parent returns the parent of the node.
        node.$text returns the node's content.

    - XMLAttrs an XMLAttrs wrapper object around XML node attributes.
        attrs.xxx returns a value of the xxx attribute.

    - Example:
        const xml = require("xml");
        let data = `<note><to b="bar" a= "foo" >Tove</to><from>Jani</from></note>`;
        let doc = xml.parse(data);

        console.log(doc.note.to.$text) /* 'Tove' */
        console.log(doc.note.to.$attr$b) /* 'bar' */
        console.log(doc.note.$tags[1].$text) /* 'Jani' */

        let dec = new TextDecoder();
        let c14n = dec.decode(xml.exclusiveC14n(doc.note));
        console.log(c14n) /* '<note><to a="foo" b="bar">Tove</to><from>Jani</from></note>' */

        c14n = dec.decode(xml.exclusiveC14n(doc.note.to));
        console.log(c14n) /* '<to a="foo" b="bar">Tove</to>' */

        c14n = dec.decode(xml.exclusiveC14n(doc.note, doc.note.to /* excluding 'to' */));
        console.log(c14n) /* '<note><from>Jani</from></note>' */

3 years agoAdded njs_vm_value_string_create() and njs_vm_value_string_create_chb().
Dmitry Volyntsev [Sat, 21 Jan 2023 04:15:03 +0000 (20:15 -0800)]
Added njs_vm_value_string_create() and njs_vm_value_string_create_chb().

Unlike njs_vm_value_string_set() the new functions always check the
input string for a valid UTF8 and calculate UTF8 character length by
themselves.

3 years agoShell: increased max output size for console.log() to 32768.
Dmitry Volyntsev [Thu, 19 Jan 2023 02:33:23 +0000 (18:33 -0800)]
Shell: increased max output size for console.log() to 32768.

3 years agoAdded njs_vm_add_module().
Dmitry Volyntsev [Sat, 7 Jan 2023 04:39:01 +0000 (20:39 -0800)]
Added njs_vm_add_module().

The new API does not require for njs_mod_t structure to be disclosed.

3 years agoFixed Object.values() and Object.entries() with external objects.
Dmitry Volyntsev [Sat, 7 Jan 2023 00:50:46 +0000 (16:50 -0800)]
Fixed Object.values() and Object.entries() with external objects.

This closes #606 issue on Github.

3 years agoFixed unitialized value usage warning.
Dmitry Volyntsev [Fri, 6 Jan 2023 06:05:03 +0000 (22:05 -0800)]
Fixed unitialized value usage warning.

Found by Coverity (CID 1518908).

3 years agoWebCrypto: improved njs_bn_bn2binpad() for OpenSSL < 1.1.0.
Dmitry Volyntsev [Thu, 5 Jan 2023 04:39:21 +0000 (20:39 -0800)]
WebCrypto: improved njs_bn_bn2binpad() for OpenSSL < 1.1.0.

The patch makes njs_bn_bn2binpad() more similar to BN_bn2binpad().

3 years agoWebCrypto: extended support for symmetric keys.
Dmitry Volyntsev [Thu, 5 Jan 2023 02:07:30 +0000 (18:07 -0800)]
WebCrypto: extended support for symmetric keys.

The following functionality for HMAC and AES-* keys were added:
    importKey() supporting 'jwk' format,
    exportKey() supporting 'jwk' and 'raw' formats,
    generateKey().

3 years agoWebCrypto: extended support for asymmetric keys.
Dmitry Volyntsev [Thu, 5 Jan 2023 01:49:22 +0000 (17:49 -0800)]
WebCrypto: extended support for asymmetric keys.

The following functionality for RSA and EC keys were added:
    importKey() supporting 'jwk' format,
                also 'raw' format for EC public keys.
    exportKey() supporting 'pksc8', 'spki', 'jwk' format,
                also 'raw' format for EC public keys.
    generateKey().

3 years agoWebCrypto: improved exception wording for invalid key formats.
Dmitry Volyntsev [Sat, 31 Dec 2022 02:22:02 +0000 (18:22 -0800)]
WebCrypto: improved exception wording for invalid key formats.

3 years agoWebCrypto: added missed support for AES-* keys of size 192.
Dmitry Volyntsev [Fri, 30 Dec 2022 04:46:21 +0000 (20:46 -0800)]
WebCrypto: added missed support for AES-* keys of size 192.

3 years agoWebCrypto: fixed importKey() for AES-* keys.
Dmitry Volyntsev [Fri, 30 Dec 2022 04:39:29 +0000 (20:39 -0800)]
WebCrypto: fixed importKey() for AES-* keys.

Previously, key of of any length were accepted, whereas according to the
spec only 128, 192 and 256 bits are allowed.

3 years agoFixed typos.
Jérémy Lal [Thu, 15 Dec 2022 12:04:46 +0000 (13:04 +0100)]
Fixed typos.

3 years agoModules: added Request, Response and Headers ctors in Fetch API.
Dmitry Volyntsev [Tue, 13 Dec 2022 06:00:23 +0000 (22:00 -0800)]
Modules: added Request, Response and Headers ctors in Fetch API.

    Added Headers method and properties: append(), delete(), get(),
        forEach(), has(), set().
    Added Request method and properties: arrayBuffer(), bodyUsed,
        cache, credentials, json(), method, mode, text(), url.
    Added Headers, Request, Response constructors.

    This closes #425 issue on Github.

3 years agoModules: fixed nginx logger callback for calls in master.
Dmitry Volyntsev [Tue, 13 Dec 2022 05:55:47 +0000 (21:55 -0800)]
Modules: fixed nginx logger callback for calls in master.

3 years agoAdded njs_vm_string_compare().
Dmitry Volyntsev [Thu, 8 Dec 2022 02:11:57 +0000 (18:11 -0800)]
Added njs_vm_string_compare().

3 years agoAdded njs_vm_external_ptr().
Dmitry Volyntsev [Thu, 8 Dec 2022 02:11:56 +0000 (18:11 -0800)]
Added njs_vm_external_ptr().

3 years agoExtended njs_vm_function_alloc().
Dmitry Volyntsev [Thu, 8 Dec 2022 02:11:56 +0000 (18:11 -0800)]
Extended njs_vm_function_alloc().

3 years agoAdded njs_value_function_set().
Dmitry Volyntsev [Thu, 8 Dec 2022 02:11:55 +0000 (18:11 -0800)]
Added njs_value_function_set().

3 years agoAllowing to declare exotic slot for the external objects.
Dmitry Volyntsev [Thu, 8 Dec 2022 02:11:54 +0000 (18:11 -0800)]
Allowing to declare exotic slot for the external objects.

3 years agoImproved performance of conditional jumps.
Vadim Zhestikov [Wed, 7 Dec 2022 02:47:53 +0000 (18:47 -0800)]
Improved performance of conditional jumps.

3 years agoFixed for(expr1; conditional syntax error handling.
Vadim Zhestikov [Fri, 18 Nov 2022 22:10:25 +0000 (14:10 -0800)]
Fixed for(expr1; conditional syntax error handling.

3 years agoShell: added signal support in CLI.
Dmitry Volyntsev [Fri, 18 Nov 2022 04:38:23 +0000 (20:38 -0800)]
Shell: added signal support in CLI.

3 years agoVersion bump.
Dmitry Volyntsev [Thu, 17 Nov 2022 02:47:36 +0000 (18:47 -0800)]
Version bump.

3 years agoAdded tag 0.7.9 for changeset 5f705230a62c
Dmitry Volyntsev [Thu, 17 Nov 2022 01:47:33 +0000 (17:47 -0800)]
Added tag 0.7.9 for changeset 5f705230a62c

3 years agoVersion 0.7.9. 0.7.9
Dmitry Volyntsev [Thu, 17 Nov 2022 01:16:36 +0000 (17:16 -0800)]
Version 0.7.9.

3 years agoAdded a target to generate pkg-config file.
Konstantin Pavlov [Mon, 17 Oct 2022 12:45:53 +0000 (16:45 +0400)]
Added a target to generate pkg-config file.

3 years agoFixed for-in unwanted detection of arrow function.
Vadim Zhestikov [Thu, 17 Nov 2022 00:09:47 +0000 (16:09 -0800)]
Fixed for-in unwanted detection of arrow function.

3 years agoFixed for-in rhs expression parsing error handling.
Vadim Zhestikov [Wed, 16 Nov 2022 17:15:39 +0000 (09:15 -0800)]
Fixed for-in rhs expression parsing error handling.

This fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53426.

3 years agoModules: fixed Fetch Response prototype reinitialization.
Dmitry Volyntsev [Wed, 16 Nov 2022 02:38:49 +0000 (18:38 -0800)]
Modules: fixed Fetch Response prototype reinitialization.

Previously, since 446a1cb64a6a (0.7.7), when at least one js_import directive
was declared in both HTTP and Stream, ngx.fetch() returned inapproriate
response in Stream.

The prototype for Response object was created two times for HTTP and STREAM,
but the second initialization of global variable with the index of the
Response() prototype overwrites the first value with a different value.  This
caused a problem in Stream code which manifested itself as a `Stream flags`
object returned as a result of ngx.fetch() call instead of a Response instance.

The fix is to ensure that shared prototypes like a Response prototype
have indentical index value in all the modules.

This fixes #596 issue on Github.

3 years agoMasks definition corrected and made regularized.
Vadim Zhestikov [Tue, 15 Nov 2022 01:31:03 +0000 (17:31 -0800)]
Masks definition corrected and made regularized.

3 years agoFixed for-in loop with left and right hand side expressions.
Vadim Zhestikov [Mon, 14 Nov 2022 17:18:37 +0000 (09:18 -0800)]
Fixed for-in loop with left and right hand side expressions.

This fixes #351 issue on Github.

3 years agoFixed Array.prototype.splice(s,d) when d resizes "this" during eval.
Dmitry Volyntsev [Fri, 11 Nov 2022 01:53:36 +0000 (17:53 -0800)]
Fixed Array.prototype.splice(s,d) when d resizes "this" during eval.

This closes #592 and #595 issues on Github.

3 years agoImproved njs_value_property_i64_delete() for fast-arrays.
Dmitry Volyntsev [Fri, 11 Nov 2022 01:53:35 +0000 (17:53 -0800)]
Improved njs_value_property_i64_delete() for fast-arrays.

3 years agoImproved njs_object_prop_define() for fast-arrays.
Dmitry Volyntsev [Fri, 11 Nov 2022 01:51:32 +0000 (17:51 -0800)]
Improved njs_object_prop_define() for fast-arrays.

Previously, any Object.defineProperty() for fast-arrays converted them
to slow ones. Now, it is only done when it is necessary.

3 years agoChange: the default JS stack size is reduced to 64k.
Dmitry Volyntsev [Thu, 10 Nov 2022 17:33:36 +0000 (09:33 -0800)]
Change: the default JS stack size is reduced to 64k.

After 86784a68e8c8 (Computed goto) the size of a stack frame
njs_vmcode_interpreter() when -O0 is specified during compilation
increased significantly.  This might cause system stack overflow for very
deep recursive calls because system stack is exausted faster than JS
stack.

It is possible now to specify JS stack size for CLI.

3 years agoFixed %TypedArray%.prototype.set(s) when s element changes "this".
Dmitry Volyntsev [Mon, 7 Nov 2022 22:22:41 +0000 (14:22 -0800)]
Fixed %TypedArray%.prototype.set(s) when s element changes "this".

This closes #590 issue on Github.

3 years agoTypes: fixed description for fs.mkdir() and fs.rmdir() methods.
Dmitry Volyntsev [Mon, 7 Nov 2022 22:22:41 +0000 (14:22 -0800)]
Types: fixed description for fs.mkdir() and fs.rmdir() methods.

This closes #600 issue on Github.

3 years agoFixed default module loader.
Dmitry Volyntsev [Mon, 7 Nov 2022 22:22:41 +0000 (14:22 -0800)]
Fixed default module loader.

Previously, njs_mp_free() was called with invalid pointer because
njs_vm_compile_module() shifts start argument to the last reading
position.

This closes #601 issue on Github.

3 years agoFixed Array.prototype.fill() when start object changes "this".
Dmitry Volyntsev [Mon, 7 Nov 2022 22:22:41 +0000 (14:22 -0800)]
Fixed Array.prototype.fill() when start object changes "this".

This fixed #589, #599 issues on Github.

3 years agoFixed String.prototype.replace(re) if re.exec() returns non-flat array.
Vadim Zhestikov [Mon, 7 Nov 2022 22:08:28 +0000 (14:08 -0800)]
Fixed String.prototype.replace(re) if re.exec() returns non-flat array.

This fixes #587 issue on Github.

3 years agoFixed static analyzer issues.
Vadim Zhestikov [Wed, 26 Oct 2022 23:33:15 +0000 (16:33 -0700)]
Fixed static analyzer issues.

3 years agoRefactored working with an object properties.
Dmitry Volyntsev [Tue, 25 Oct 2022 16:19:32 +0000 (09:19 -0700)]
Refactored working with an object properties.

1) njs_object_prop_t is compacted from 72 to 40 bytes on 64bit
platforms.
2) njs_object_prop_define() is revorked to accomodate fast
property creation using njs_value_create_data_prop()
which corresponds to CreateDataProperty() from the specs.

3 years agoVersion bump.
Dmitry Volyntsev [Tue, 25 Oct 2022 16:19:14 +0000 (09:19 -0700)]
Version bump.

3 years agoComputed goto support added to vmcode.
Vadim Zhestikov [Tue, 25 Oct 2022 13:43:10 +0000 (06:43 -0700)]
Computed goto support added to vmcode.

3 years agoAdded tag 0.7.8 for changeset 3308415d7de8
Dmitry Volyntsev [Tue, 25 Oct 2022 05:49:55 +0000 (22:49 -0700)]
Added tag 0.7.8 for changeset 3308415d7de8

3 years agoVersion 0.7.8. 0.7.8
Dmitry Volyntsev [Tue, 25 Oct 2022 04:29:44 +0000 (21:29 -0700)]
Version 0.7.8.