]>
git.kaiwu.me - njs.git/log
Dmitry Volyntsev [Mon, 1 Feb 2021 01:16:51 +0000 (02:16 +0100)]
Fixed safe mode bypass in Function constructor.
This closes #367 pull request on Github.
Thanks bux.patryk@gmail.com for prodding it.
Dmitry Volyntsev [Mon, 1 Feb 2021 16:13:10 +0000 (16:13 +0000)]
HTTP: fixed module type introduced in
c0c6539ae445 .
Dmitry Volyntsev [Mon, 1 Feb 2021 12:24:17 +0000 (12:24 +0000)]
HTTP: added js header filter.
Dmitry Volyntsev [Tue, 26 Jan 2021 12:52:17 +0000 (12:52 +0000)]
Fixed Headers object keys forgotten in
81040de6b085 .
Found by Coverity (CID
1472501 ).
Dmitry Volyntsev [Tue, 26 Jan 2021 12:52:15 +0000 (12:52 +0000)]
Fixed allocation failure detection in njs_backtrace_to_string().
Found by Coverity (CID
1472503 ).
Dmitry Volyntsev [Tue, 26 Jan 2021 12:52:12 +0000 (12:52 +0000)]
Fixed typo introduced in
81040de6b085 .
Found by Coverity (CID
1472504 , CID
1472505 ).
Dmitry Volyntsev [Thu, 21 Jan 2021 18:44:58 +0000 (18:44 +0000)]
Modules: added ngx.fetch().
This is an initial implementation of Fetch API.
The following init options are supported:
body, headers, buffer_size (nginx specific), max_response_body_size
(nginx specific), method.
The following properties and methods of Response object are implemented:
arrayBuffer(), bodyUsed, json(), headers, ok, redirect, status, statusText,
text(), type, url.
The following properties and methods of Header object are implemented:
get(), getAll(), has().
Notable limitations: only http:// scheme is supported, redirects
are not handled.
In collaboration with 洪志道 (Hong Zhi Dao).
Dmitry Volyntsev [Mon, 11 Jan 2021 19:53:10 +0000 (19:53 +0000)]
Added njs_vm_object_keys().
Dmitry Volyntsev [Mon, 11 Jan 2021 19:53:09 +0000 (19:53 +0000)]
Added njs_value_null_set().
Dmitry Volyntsev [Mon, 11 Jan 2021 19:53:09 +0000 (19:53 +0000)]
Allowing to reserve 0 bytes in njs_chb_reserve() for consistency.
Dmitry Volyntsev [Mon, 11 Jan 2021 19:53:08 +0000 (19:53 +0000)]
Exposing chb API.
Dmitry Volyntsev [Mon, 11 Jan 2021 19:53:08 +0000 (19:53 +0000)]
Added njs_vm_value_array_buffer_set().
Dmitry Volyntsev [Mon, 11 Jan 2021 19:53:05 +0000 (19:53 +0000)]
2021 year.
Dmitry Volyntsev [Thu, 24 Dec 2020 18:35:18 +0000 (18:35 +0000)]
Refactored working with external prototypes.
Previously, njs_vm_external_prototype() returned the pointer to a
created prototype structure. Which were expected to be passed to
njs_vm_external_create() as is. The returned pointer is needed to be
stored somewhere by user code which complicates user code in cases when
many prototypes are created.
Instead, an index in the VM internal table is returned.
njs_vm_external_create() is changed accordingly. This simplifies
user code because the index is known at static time for most cases.
Dmitry Volyntsev [Wed, 23 Dec 2020 11:27:50 +0000 (11:27 +0000)]
Stream: simplified vm events handling.
No functional changes.
Disconnect3d [Tue, 22 Dec 2020 12:27:01 +0000 (13:27 +0100)]
Fixed encoding matching for base64url in String.bytesFrom().
This closes #363 PR on GitHub.
Dmitry Volyntsev [Wed, 16 Dec 2020 20:27:43 +0000 (20:27 +0000)]
Avoiding modification of vm->retval in njs_add_event().
Dmitry Volyntsev [Wed, 16 Dec 2020 20:27:31 +0000 (20:27 +0000)]
Avoiding modification of vm->retval in njs_promise_alloc().
Alloc functions are not expected to modify existing values.
Dmitry Volyntsev [Wed, 16 Dec 2020 20:27:27 +0000 (20:27 +0000)]
Version bump.
Dmitry Volyntsev [Tue, 1 Dec 2020 12:59:48 +0000 (12:59 +0000)]
Added tag 0.5.0 for changeset
69f07c615162
Dmitry Volyntsev [Tue, 1 Dec 2020 12:32:31 +0000 (12:32 +0000)]
Version 0.5.0.
Jakub Jirutka [Tue, 24 Nov 2020 23:12:04 +0000 (00:12 +0100)]
Types: added definitions for timer methods.
Dmitry Volyntsev [Fri, 27 Nov 2020 13:17:53 +0000 (13:17 +0000)]
Types: added description for Buffer properties.
Dmitry Volyntsev [Fri, 27 Nov 2020 12:28:44 +0000 (12:28 +0000)]
HTTP: renaming reqBody,resBody to requestBuffer and responseBuffer.
In
434f20c29f4c , r.reqBody and r.resBody were introduced. Since quite
often request body and response body are valid strings, it is preferable
to leave both variants to avoid potential conversions.
To make distinction clearer, requestText and responseText aliases to
requestBody and responseBody were also added.
Alexander Borisov [Thu, 26 Nov 2020 18:43:17 +0000 (21:43 +0300)]
Modules: fixed promise events handling.
Previously, promise chain might not be invoked at all in some cases.
Specifically, this happened in HTTP module if promise chain did not start
with a r.subrequest() invocation.
The fix is to always process all pending promise events after the main module
function.
This closes #359 issue on GitHub.
Dmitry Volyntsev [Thu, 26 Nov 2020 11:36:03 +0000 (11:36 +0000)]
Modules: renaming vars to rawVariables to better reflect purpose.
In
434f20c29f4c , obj.vars was introduced. obj.vars is almost identical
to obj.variables except a value of the Buffer type is returned.
Since most nginx variables are valid strings, it is preferable to
leave both variants.
To avoid confusion rawVariables name is used for Buffer variables.
Dmitry Volyntsev [Thu, 26 Nov 2020 11:11:01 +0000 (11:11 +0000)]
Types: added description for "ngx" object.
Dmitry Volyntsev [Thu, 26 Nov 2020 11:10:59 +0000 (11:10 +0000)]
Types: extending data types for methods with NjsStringLike args.
Dmitry Volyntsev [Wed, 25 Nov 2020 10:47:47 +0000 (10:47 +0000)]
Modules: introduced Buffer alternatives for object properties.
Buffer variant returns the property bytes as is, whereas the string
version may convert bytes invalid in UTF-8 encoding into replacement
character.
HTTP
new request object properties:
r.reqBody (r.requestBody),
r.resBody (r.responseBody),
r.vars (r.variables).
Stream
new stream object properties:
s.vars (s.variables).
new events:
The events' callbacks are identical to the string counterparts, except the data
argument:
upstream (upload),
downstream (download).
Dmitry Volyntsev [Wed, 25 Nov 2020 10:47:25 +0000 (10:47 +0000)]
Stream: improved vm events handling.
Valentin Bartenev [Fri, 20 Nov 2020 09:29:30 +0000 (12:29 +0300)]
Ignoring pcre_study() error.
It provides optional optimization that shouldn't be fatal for regex compilation.
Dmitry Volyntsev [Wed, 18 Nov 2020 18:09:11 +0000 (18:09 +0000)]
HTTP: fixed promise subrequest() with error_page redirect.
Previously, promise callbacks for a subrequest were stored in a
subrequest context. This is incorrect because a subrequest content may
be destroyed (for example when error_page with redirect is enabled for a
subrequest location).
The fix is to store callbacks in the parent context.
The issue was introduced in
6fccbc9f1288 (0.3.8).
Dmitry Volyntsev [Tue, 17 Nov 2020 13:22:34 +0000 (13:22 +0000)]
Modules: added support for Buffer object where string is expected.
Dmitry Volyntsev [Tue, 17 Nov 2020 13:16:47 +0000 (13:16 +0000)]
Stream: linking ngx object to the module missed in
d7f6e719af98 .
Dmitry Volyntsev [Fri, 2 Oct 2020 18:38:12 +0000 (18:38 +0000)]
Modules: introduced global "ngx" object.
Dmitry Volyntsev [Fri, 13 Nov 2020 15:08:05 +0000 (15:08 +0000)]
Configure: improved dependencies tracking.
Using nginx Makefile as a dependency for libnjs.a to ensure
libnjs.a is rebuilt after auto/configure invocation.
Dmitry Volyntsev [Tue, 10 Nov 2020 17:46:01 +0000 (17:46 +0000)]
Introduced a library of common functionality for the modules.
Dmitry Volyntsev [Mon, 9 Nov 2020 11:54:55 +0000 (11:54 +0000)]
Removed unused key field from njs_hmac_t.
Artem S. Povalyukhin [Sun, 25 Oct 2020 15:29:15 +0000 (18:29 +0300)]
Introduced initial iterator support.
Dmitry Volyntsev [Fri, 6 Nov 2020 11:41:32 +0000 (11:41 +0000)]
Fixed querystring.parse().
The issue happened when the first eq symbol is located after the
separator, whereas it should be looked for only in the string segment
before the separator.
This fixes #349 issue on Github.
Alexander Borisov [Tue, 3 Nov 2020 12:31:41 +0000 (15:31 +0300)]
Promise: tracking unhandled promise rejection.
By default, promises should finish processing normally for .then(),
.catch(), .finally() and so on. The patch adds the ability to report
unhandled exception from promises to the user.
This closes #346 issue on GitHub.
Alexander Borisov [Tue, 3 Nov 2020 17:14:33 +0000 (20:14 +0300)]
Promise: fixed the catch handler for Promise.prototype.finally().
By spec, the catch handler for the .finally() should always return an
exception.
The issue was introduced in
61bf7a31e685 .
Artem S. Povalyukhin [Sat, 31 Oct 2020 20:00:03 +0000 (23:00 +0300)]
Fixed querystring.stringify().
Jakub Jirutka [Sat, 31 Oct 2020 21:38:22 +0000 (22:38 +0100)]
Types: fixed signature of subrequest() with detached: true.
Order of method overloading declaration matters.
Jakub Jirutka [Thu, 29 Oct 2020 12:51:21 +0000 (12:51 +0000)]
Types: refactored ts_test.
Jakub Jirutka [Thu, 29 Oct 2020 12:50:05 +0000 (12:50 +0000)]
Types: refactored working with TypeScript API description.
Jakub Jirutka [Mon, 19 Oct 2020 21:18:22 +0000 (23:18 +0200)]
Types: fixed index types in modules.
Fixes the following type errors:
Property ''xxx'' of type 'NjsByteString | undefined' is not
assignable to string index type 'NjsStringLike'.ts(2411)
While string index signatures are a powerful way to describe the
"dictionary" pattern, they also enforce that all properties match
their return type.
Jakub Jirutka [Sat, 24 Oct 2020 21:59:18 +0000 (23:59 +0200)]
Types: added missing var "console" into njs_shell.
Jakub Jirutka [Tue, 20 Oct 2020 19:16:20 +0000 (21:16 +0200)]
Types: added tsconfig.json and package.json for type descriptions.
Jakub Jirutka [Mon, 19 Oct 2020 21:51:54 +0000 (23:51 +0200)]
Types: moved all TS type descriptions to ts/ in the repo root.
Jakub Jirutka [Thu, 22 Oct 2020 20:45:00 +0000 (22:45 +0200)]
Introduced .hgignore.
Jakub Jirutka [Wed, 21 Oct 2020 23:51:31 +0000 (01:51 +0200)]
Configure: refactored NJS_VER.
Dmitry Volyntsev [Thu, 29 Oct 2020 12:46:19 +0000 (12:46 +0000)]
Configure: generating $NJS_LIB_OBJS using sed.
Jakub Jirutka [Mon, 19 Oct 2020 19:42:01 +0000 (21:42 +0200)]
Types: mark String.bytesFrom() in as deprecated.
Jakub Jirutka [Fri, 9 Oct 2020 15:28:58 +0000 (17:28 +0200)]
Added TypeScript description for crypto module.
Jakub Jirutka [Fri, 9 Oct 2020 15:05:47 +0000 (17:05 +0200)]
Added TypeScript description for querystring module.
Jakub Jirutka [Fri, 9 Oct 2020 00:33:31 +0000 (02:33 +0200)]
Added TypeScript description for fs module.
Jakub Jirutka [Fri, 16 Oct 2020 23:38:31 +0000 (01:38 +0200)]
Added TypeScript description for Buffer type.
Alexander Borisov [Tue, 20 Oct 2020 11:00:40 +0000 (14:00 +0300)]
Added support for Object.prototype.valueOf() in Buffer.from().
Missed in
27bb9caf186c .
Alexander Borisov [Mon, 19 Oct 2020 12:51:37 +0000 (15:51 +0300)]
Fixed returned value for Buffer.prototype.write* functions.
All Buffer.prototype.write* functions must return offset plus
the number of bytes written.
The issue was introduced in
27bb9caf186c .
Alexander Borisov [Tue, 13 Oct 2020 12:44:33 +0000 (15:44 +0300)]
Fixed heap-buffer-overflow for RegExp.prototype[Symbol.replace].
Previously, RegExp.prototype[Symbol.replace] might overrun the boundaries
of the result of the custom "exec" method for a RegExp argument. The
issue occurred when the result object had zero length. The length is
used to create an array and the zero index was always written without
respect for the length resulting is heap-buffer-overflow.
The issue was introduced in
1c729f765cfb .
Alexander Borisov [Thu, 8 Oct 2020 15:47:04 +0000 (18:47 +0300)]
HTTP: throwing an exception in internalRedirect() for a subrequest.
This closes #214 issue on GitHub.
Alexander Borisov [Tue, 6 Oct 2020 17:51:56 +0000 (20:51 +0300)]
Fixed JSON.stringify() for arrays resizable via getters.
Alexander Borisov [Tue, 6 Oct 2020 17:24:21 +0000 (20:24 +0300)]
Fixed heap-use-after-free in JSON.stringify().
njs_json_stringify_iterator() assumed, while stringifying flat arrays, that a
flat array will always remain flat. This is not the case for flat arrays with
values with custom getters which may modify the enclosing array upon
invocation.
This closes #322 issue on GitHub.
Alexander Borisov [Tue, 6 Oct 2020 16:53:26 +0000 (19:53 +0300)]
Fixed heap-use-after-free in JSON.parse().
This correctly fixes the issues addressed in 1405:
9beb9ea093b5 .
The initial fix wrongly assumed that the "value" pointer is still valid when
njs_is_fast_array(&state->value) is true and the pointer can be used for
the fast path. This is not the case when the array object is resized.
Moreover, the fast path branch may be completely eliminated because
JSON.parse() with the replacer function is relatively slow by itself.
This closes #323, #324, #325 issues on GitHub.
Dmitry Volyntsev [Fri, 2 Oct 2020 12:18:44 +0000 (12:18 +0000)]
Improved working with the path argument in "fs" module.
Dmitry Volyntsev [Fri, 2 Oct 2020 12:18:41 +0000 (12:18 +0000)]
Version bump.
Dmitry Volyntsev [Tue, 29 Sep 2020 13:32:37 +0000 (13:32 +0000)]
Added tag 0.4.4 for changeset
fdfd580b0dd6
Dmitry Volyntsev [Tue, 29 Sep 2020 13:31:47 +0000 (13:31 +0000)]
Version 0.4.4.
Dmitry Volyntsev [Mon, 28 Sep 2020 17:45:44 +0000 (17:45 +0000)]
Adding support for Buffer objects in "fs" methods.
fs.writeFile(), fs.appendFile() and friends may accept an instance of
Buffer as an argument.
Also, fs.readFile() and friends now return an instance of Buffer instead of
Byte-string when encoding is not provided.
Added Buffer encoding for fs.readdir(), fs.realpath() and friends.
Dmitry Volyntsev [Mon, 28 Sep 2020 16:59:35 +0000 (16:59 +0000)]
Fixed njs_buffer_set() introduced in
27bb9caf186c .
Previously an instance of Uint8Array was returned, not Buffer.
Dmitry Volyntsev [Thu, 24 Sep 2020 19:00:38 +0000 (19:00 +0000)]
Fixed dead store assignment after
eef4ab1bee70 .
Found by Clang static analyzer.
Dmitry Volyntsev [Tue, 22 Sep 2020 18:42:21 +0000 (18:42 +0000)]
Adding support for Buffer objects in crypto methods.
Dmitry Volyntsev [Mon, 21 Sep 2020 17:15:10 +0000 (17:15 +0000)]
Fixed unit test on big-endian platforms.
Dmitry Volyntsev [Fri, 18 Sep 2020 18:00:32 +0000 (18:00 +0000)]
Added support for detached-buffers.
Alexander Borisov [Thu, 17 Sep 2020 10:10:51 +0000 (13:10 +0300)]
Added forgotten 'break' statement missed in
27bb9caf186c .
Found by Coverity (CID
1466731 ).
Alexander Borisov [Wed, 16 Sep 2020 14:22:01 +0000 (17:22 +0300)]
Introduced Buffer implementation.
Dmitry Volyntsev [Fri, 11 Sep 2020 13:54:57 +0000 (13:54 +0000)]
HTTP: added support for http/2 and http/3 in r.httpVersion.
Alexander Borisov [Mon, 7 Sep 2020 14:55:24 +0000 (17:55 +0300)]
Fixed TextDecoder.prototype.decode() with non-zero TypedArray offset.
Alexander Borisov [Mon, 7 Sep 2020 14:55:10 +0000 (17:55 +0300)]
Added support for ArrayBuffer in TextDecoder.prototype.decode().
This closes #331 issue on Github.
Alexander Borisov [Mon, 7 Sep 2020 14:54:47 +0000 (17:54 +0300)]
Separating string length counting and encoding conversion.
Dmitry Volyntsev [Mon, 7 Sep 2020 12:44:07 +0000 (12:44 +0000)]
Added %TypedArray% remaining methods.
The following methods were added: of(), from().
Dmitry Volyntsev [Thu, 3 Sep 2020 13:30:17 +0000 (13:30 +0000)]
Fixed TextDecoder() test on big-endian platforms.
Dmitry Volyntsev [Thu, 3 Sep 2020 13:30:16 +0000 (13:30 +0000)]
Fixed TypedArraySpeciesCreate().
According to the spec, it is expected to verify that created
typed-array instance has appropriate length.
Dmitry Volyntsev [Thu, 3 Sep 2020 13:30:15 +0000 (13:30 +0000)]
Fixed RegExp.prototype[Symbol.replace] when replace val is function.
Previously, a custom function received garbage value as the first
argument.
Dmitry Volyntsev [Tue, 1 Sep 2020 17:25:33 +0000 (17:25 +0000)]
Fixed RegExpBuiltinExec() with global flag and byte-strings.
The issue was introduced in
f9082cd59ba6 (0.4.2). Since
1c729f765cfb
(0.4.2) RegExp.prototype[Symbol.replace] with a regexp with the global
flag may result in an endless loop for byte-strings with broken UTF8
encoding.
Dmitry Volyntsev [Tue, 1 Sep 2020 16:37:33 +0000 (16:37 +0000)]
Added DataView object.
Dmitry Volyntsev [Fri, 28 Aug 2020 11:51:35 +0000 (11:51 +0000)]
Introduced copy-on-write for ArrayBuffer.
Dmitry Volyntsev [Fri, 28 Aug 2020 11:48:22 +0000 (11:48 +0000)]
Aligning switch statements in njs_typed_array_prototype_iterator().
Merging NJS_ARRAY_FILTER case to default case for all switch statements.
This makes code more static-analyzer friendly.
Dmitry Volyntsev [Fri, 28 Aug 2020 11:47:50 +0000 (11:47 +0000)]
Fixed double close in njs_ftw() introduced in
5a80b43b7098 .
This correctly fixes Coverity CID
1465877 .
Dmitry Volyntsev [Thu, 27 Aug 2020 14:43:23 +0000 (14:43 +0000)]
Introduced njs_assert() macro.
Dmitry Volyntsev [Thu, 27 Aug 2020 14:43:22 +0000 (14:43 +0000)]
Splitting debug and debug-memory configure options.
Dmitry Volyntsev [Thu, 27 Aug 2020 14:43:19 +0000 (14:43 +0000)]
Parser: fixed njs_queue_remove() macro usage.
The issue caused segfault when NJS_DEBUG is defined.
The issue was introduced in
86f55a7dc4a4 .
Alexander Borisov [Wed, 26 Aug 2020 18:11:03 +0000 (21:11 +0300)]
Fixed return value for string base64/base64url encoding.
Alexander Borisov [Wed, 26 Aug 2020 18:05:46 +0000 (21:05 +0300)]
Improved UTF-8 encoding/decoding.
Dmitry Volyntsev [Wed, 26 Aug 2020 14:56:47 +0000 (14:56 +0000)]
Fixed String.prototype.indexOf() for byte-strings.
The issue was introduced in
e8a941b394a3 (0.4.3).
This closes #335 issue on Github.
Dmitry Volyntsev [Wed, 26 Aug 2020 14:55:47 +0000 (14:55 +0000)]
Generator: simplified runtime errors generation.
Dmitry Volyntsev [Wed, 26 Aug 2020 14:55:28 +0000 (14:55 +0000)]
Adapted expect tests after
775c81dcbe61 .
Dmitry Volyntsev [Mon, 24 Aug 2020 11:28:21 +0000 (11:28 +0000)]
Fixed function "constructor" property handler while setting.
Dmitry Volyntsev [Fri, 21 Aug 2020 13:07:54 +0000 (13:07 +0000)]
Improved njs.dump() with built-in functions.