Commit graph

20692 commits

Author SHA1 Message Date
Jean Boussier
ee0de3fd4e [ruby/json] JSON.dump: write directly into the provided IO
Ref: https://github.com/ruby/json/issues/524

Rather than to buffer everything in memory.

Unfortunately Ruby doesn't provide an API to write into
and IO without first allocating a string, which is a bit
wasteful.

f017af6c0a
2024-11-26 15:11:05 +09:00
Hiroshi SHIBATA
8655b9f7c6 [ruby/uri] Suppress deprecate warning of test class and use EnvUtil.suppress_warning.
bd2e4be9d0
2024-11-26 03:32:01 +00:00
Hiroshi SHIBATA
1d9dc4c504 [ruby/uri] Revert "Prevent a warning: URI::REGEXP is obsolete
(https://github.com/ruby/uri/pull/138)"

This reverts commit c00726a20a.

22f5a7a790
2024-11-26 03:32:01 +00:00
Nobuyoshi Nakada
6b4f8945d6 Many of Oniguruma functions need valid encoding strings 2024-11-26 11:46:34 +09:00
Nobuyoshi Nakada
02b70256b5 Check negative integer underflow 2024-11-26 11:46:34 +09:00
Hiroshi SHIBATA
c08e1f336c [ruby/resolv] Omit Windows and MinGW platforms with with_udp_and_tcp
3351165599

```
  => 705:     with_udp_and_tcp('127.0.0.1', 0) do |u1, t1|
     706:       with_udp_and_tcp('127.0.0.1', 0) do |u2,t2|
     707:         u2.close # XXX: u2 UDP socket is not used, but using #with_udp_and_tcp to enable Windows EACCES workaround
     708:         _, server1_port, _, server1_address = u1.addr
Error: Errno::EACCES: Permission denied - bind(2) for "127.0.0.1" port 55685
```

3346106852

```
    1) Error:
  TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback:
  Errno::EACCES: Permission denied - bind(2) for "127.0.0.1" port 50676
      D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer#initialize'
      D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TCPServer.new'
      D:/a/ruby/ruby/src/test/resolv/test_dns.rb:78:in 'TestResolvDNS#with_udp_and_tcp'
      D:/a/ruby/ruby/src/test/resolv/test_dns.rb:705:in 'TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback'
```

05765df178
2024-11-26 02:44:00 +00:00
Hiroshi SHIBATA
36f67f6bbb [ruby/resolv] _1 is not provided in Ruby 2.5
83f18e2a49
2024-11-26 00:28:06 +00:00
dependabot[bot]
cdd47436ae [rubygems/rubygems] Bump the rb-sys group across 2 directories with 1 update
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).

Updates `rb-sys` from 0.9.102 to 0.9.103
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.102...v0.9.103)

Updates `rb-sys` from 0.9.102 to 0.9.103
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.102...v0.9.103)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
...

Signed-off-by: dependabot[bot] <support@github.com>

31b8a68dd5
2024-11-25 18:35:02 +00:00
tomoya ishida
0f41cc442e [ruby/reline] Fix tab completion appending quote
(https://github.com/ruby/reline/pull/782)

cbf213291c
2024-11-25 17:38:50 +00:00
Yusuke Endoh
6ab76a6212 [rubygems/rubygems] Prevent a warning: net/http: Content-Type did not set
`make test-all RUBYOPT=-w` in the ruby/ruby repo printed the warning.
This change prevents the warning by specifying the content-type
explicitly.

A follow-up to b70c1bb150

d573af07f6
2024-11-25 10:13:32 +00:00
Nobuyoshi Nakada
a355f7d351 [ruby/open-uri] Use ENV.update
04067e54b9
2024-11-25 08:00:03 +00:00
Yusuke Endoh
da8f554011 [ruby/uri] Prevent a warning: URI::REGEXP is obsolete
(https://github.com/ruby/uri/pull/138)

c00726a20a
2024-11-25 07:28:52 +00:00
Yusuke Endoh
f78f1e927f Prevent a warning: setting Encoding.default_external 2024-11-25 15:45:00 +09:00
Misaki Shioi
ff5fc4b5a1
Do not save the last error without sockets in the connection attempt (#12153)
* Do not save the last_error if there are no sockets waiting to be connected

In this implementation, the results of both name resolution and connection attempts are awaited using select(2).
When it returned, the implementation attempted to check for connections even if there were no sockets currently attempting to connect, treating the absence of connected sockets as a connection failure.
With this fix, it will no longer check for connections when there are no sockets waiting to be connected.

Additionally, the following minor fixes have been made:

* Handle failure of getsockopt(2) and removed unnecessary continue in the loop

* Tweak: Use common API to check in_progress_fds

* Safely call TCPServer.new in test

* Set empty writefds when there is no socket waiting to be connected

* Enable fast_fallback option
2024-11-25 14:10:54 +09:00
Hiroshi SHIBATA
30fda41139
Removed redundant argument at Reline::LineEditor::CompletionBlockTest 2024-11-25 08:16:53 +09:00
tomoya ishida
bf47b1b523 [ruby/reline] Fix completion quote, preposing and target calculation
bug
(https://github.com/ruby/reline/pull/763)

d3ba7216eb
2024-11-24 15:45:18 +00:00
Samuel Williams
a8c2d5e7be
Ensure fiber scheduler re-acquires mutex when interrupted from sleep. (#12158)
[Bug #20907]
2024-11-23 23:54:12 +00:00
Josh Cooper
b4d13fac3d [ruby/openssl] Support signing CRLs using Ed25519
Allow CRLs to be signed using Ed25519 private keys by passing a nil digest.

b62375bcde
2024-11-22 17:26:03 +00:00
Josh Cooper
6389c9a395 [ruby/openssl] Support signing requests using Ed25519
Allow requests to be signed using Ed25519 private keys by passing a nil digest.
This is similar to commit b0fc100091 when signing certs.

Calling PKey#public_key is deprecated and does not work for Ed25519. The same
can be accomplished by passing the private key.

d96090320d
2024-11-22 17:26:02 +00:00
Josh Cooper
ce4906efb3 [ruby/openssl] Check for compatible openssl versions earlier
test_pkey wasn't checking for libressl as is done elsewhere.

Note the libressl version check is different when testing pkey, because
PKey#sign relies on EVP_PKey_sign, whereas signing an X509 cert/request/crl
relies on ASN1_item_sign.

f1db5c88a2
2024-11-22 17:26:02 +00:00
Matt Valentine-House
680e060026 [prism/compiler] end_cursor should never be NULL
This fixes a failed assertion reported to SimpleCov

https://github.com/simplecov-ruby/simplecov/issues/1113

This can be repro'd as follows:

1. Create a file `test.rb` containing the following code

```
@foo&.(@bar)
```

2. require it with branch coverage enabled

```
ruby -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'"
```

The assertion is failing because the Prism compiler is incorrectly
detecting the start and end cursor position of the call site for the
implicit call .()

This patch replicates the parse.y behaviour of setting the default
end_cursor to be the final closing location of the call node.

This behaviour can be verified against `parse.y` by modifying the test
command as follows:

```
ruby --parser=parse.y -rcoverage -e "Coverage.start(branches: true); require_relative 'test.rb'"
```

[Bug #20866]
2024-11-21 13:51:59 +00:00
Samuel Williams
b143fd5bd8 [ruby/zlib] Don't call rb_str_set_len while released the GVL.
(https://github.com/ruby/zlib/pull/88)

* Only release the GVL where necessary.

- Several string manipulation methods were invoked while the GVL was
  released. This is unsafe.
- The mutex protecting multi-threaded access was not covering buffer state
  manipulation, leading to data corruption and out-of-bounds writes.
- Using `rb_str_locktmp` prevents changes to buffer while it's in use.

[Bug #20863]

e445cf3c80
2024-11-20 21:02:16 +00:00
Samuel Giddins
b70c1bb150 [rubygems/rubygems] Add --attestation option to gem push
Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

a5412d9a0e
2024-11-20 19:32:49 +00:00
Thierry Deo
2bf5d26eb9 [ruby/psych] Eagerly require date.
b2aa0032c0
2024-11-20 16:59:55 +00:00
Jeremy Evans
3b7892b6e4 Fix a bug in rb_include_module that stops nested inclusion into module subclasses
This bug was present since the code was originally added by me
in 3556a834a2.

Fixes [Bug #20871]
2024-11-20 07:59:31 -08:00
Samuel Williams
9c268302bf
Introduce Fiber::Scheduler#blocking_operation_wait. (#12016)
Redirect `rb_nogvl` blocking operations to the fiber scheduler if possible
to prevent stalling the event loop.

[Feature #20876]
2024-11-20 19:40:17 +13:00
tompng
7b51b3c75b [ruby/pp] Fix pretty printing range begin/end with false or nil
6d9c0f255a
2024-11-19 14:52:01 +00:00
tomoya ishida
bc92379664 [ruby/irb] Don't use delegator to install helper methods to main
object
(https://github.com/ruby/irb/pull/1031)

IRB used delegator to install command as a method of frozen main object.
Command is not a method now. We can drop it.

2f1c593801
2024-11-19 13:17:11 +00:00
Shugo Maeda
7ed027a833 Remove deprecated method Refinement#refined_class
[Feature #20901]
2024-11-19 14:33:38 +09:00
Nobuyoshi Nakada
9c777f282f
[Bug #20900] Warn deprecated constant when removing 2024-11-19 12:43:38 +09:00
Stan Lo
ee0915feeb [ruby/rdoc] Extract excerpt from raw pages correctly
(https://github.com/ruby/rdoc/pull/1200)

Fixes https://bugs.ruby-lang.org/issues/20862

3c678249e2
2024-11-18 10:32:31 +00:00
Misaki Shioi
84470d72c5
Disable HEv2 tests temporarily (#12097)
* Disable HEv2 tests temporarily

To suppress error log output in CI.
They should have been DISABLE in PR #12070.

---

Additionally, the following fixes have been made:

- Remove unnecessary `assert_separately` from the related tests
2024-11-15 18:12:37 +09:00
Misaki Shioi
51666c827b
Make fast_fallback option false by default temporarily (#12070)
to suppress failing output in CI.
2024-11-15 09:18:09 +09:00
Dave Corson-Knowles
facb82aba5 [rubygems/rubygems] Update test_project_sanity.rb
279eefb8a3
2024-11-14 23:21:05 +00:00
tomoya ishida
8f3a6ebcf4 [ruby/reline] Drop loading terminfo, remove fiddle dependency in
non-windows environment.
(https://github.com/ruby/reline/pull/769)

Reline works perfectly in most major terminal emulators without terminfo.
In minor/old terminal emulator, we used to get key bindings from terminfo, but I think it is not used so much.

3ceba3bff7
2024-11-14 23:14:18 +00:00
Misaki Shioi
fd4b27472e
Do not wait connection attempt delay without in progress fds (#12087)
Do not wait Connection Attempt Delay without in progress fds

Reset Connection Attempt Delay when connection fails and there is no other socket connection in progress.
This is intended to resolve an issue that was temporarily worked around in Pull Request #12062.

`TCPServer::new` (used in tests such as `TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write`) can only connect over either IPv6 or IPv4, depending on the environment.
Since HEv2 attempts to connect over IPv6 first, environments where IPv6 connections are unavailable return ECONNREFUSED immediately.
In such cases, the client should immediately retry the connection over IPv4.
However, HEv2 includes a specification for a "Connection Attempt Delay," where it waits 250ms after the previous connection attempt before starting the next one.
This delay causes Net::OpenTimeout (100ms) to be exceeded while waiting for the next connection attempt to start.

With this change, when a connection attempt fails, if there are sockets still attempting to connect and there are addresses yet to be tried, the Connection Attempt Delay will be resetted, allowing the next connection attempt to start immediately.

---

Additionally, the following minor fixes have been made:

- The `nfds` value used for select(2) is now reset with each wait.
2024-11-15 00:25:59 +09:00
Matt Valentine-House
42501015b4 rb_raise when attempting to set the GC implementation name
Instead of silently ignoring the key, we should raise to clearly tell
the user that this key is read-only.
2024-11-14 10:46:36 +00:00
Matt Valentine-House
ee290c94a3 Include the currently active GC in RUBY_DESCRIPTION
This will add +MOD_GC to the version string and Ruby description when
Ruby is compiled with shared gc support.

When shared GC support is compiled in and a GC module has been loaded
using RUBY_GC_LIBRARY, the version string will include the name of
the currently active GC as reported by the rb_gc_active_gc_name function
in the form

+MOD_GC[gc_name]

[Feature #20794]
2024-11-14 10:46:36 +00:00
Matt Valentine-House
fa10441981 Expose GC.config[:implementation], to query the currently active GC
And a default and readonly key to the GC.config hash that names the
current GC implementation.

This is provided by each implementation by the API function
rb_gc_impl_active_gc_name
2024-11-14 10:46:36 +00:00
Kazuki Yamaguchi
a0f1f16145 asn1: fix ObjectId#==
Compare by the dotted decimal notation rather than the NID.

OpenSSL::ASN1::ObjectId can store OIDs that are not registered in
OpenSSL's internal table. NID is not defined for such an OID, but it is
not an error.

The == method also should not raise TypeError if the other object is
not an instance of OpenSSL::ASN1::ObjectId.

Fixes: https://github.com/ruby/openssl/issues/791
2024-11-14 11:21:39 +09:00
Kazuki Yamaguchi
419fb2f3b9 [ruby/openssl] x509: fix handling of multiple URIs in Certificate#crl_uris
The implementation of OpenSSL::X509::Certificate#crl_uris makes the
assumption that each DistributionPoint in the CRL distribution points
extension contains a single general name of type URI. This is not
guaranteed by RFC 5280. A DistributionPoint may contain zero or more
than one URIs.

Let's include all URIs found in the extension. If only non-URI pointers
are found, return nil.

Fixes: https://github.com/ruby/openssl/issues/775

71f4fef2fa
2024-11-14 11:21:39 +09:00
Kazuki Yamaguchi
97be56fc62 [ruby/openssl] test_x509cert.rb: break up test_extension into smaller units
test_extesion is testing too many features at once and is hard to
navigate. Let's split each chunk apart for more clarity.

461cfcb070
2024-11-14 11:21:39 +09:00
Hiroshi SHIBATA
1bab8bf88f [ruby/uri] Removed duplicated declare step for constants under the URI::RFC2396_REGEXP::PATTERN
60a8bc1575
2024-11-14 02:20:04 +00:00
Hiroshi SHIBATA
1d6c986104 [ruby/uri] Restore constants like URI::REGEXP::PATTERN::IPV6ADDR
ee9a38701a
2024-11-14 02:20:04 +00:00
Takashi Kokubun
01db456196 Move Array#map to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-11-13 12:27:26 -08:00
HoneyryderChuck
2335768437 [ruby/openssl] make bn shareable when frozen
d3c8e661e8
2024-11-13 07:25:51 +00:00
Jean Boussier
ee1cd1656f ObjectSpace.dump: handle Module#set_temporary_name
[Bug #20892]

Until the introduction of that method, it was impossible for a
Module name not to be valid JSON, hence it wasn't going through
the slower escaping function.

This assumption no longer hold.
2024-11-12 20:21:27 +01:00
Peter Zhu
eca3680c27 [ruby/prism] Fix use of uninitialized value when parsing regexp
Parsing the regexp /\A{/ causes uses an uninitialized value because it
tries to parse it as a range quantifier, so it reads the character after
the closing curly bracket. This is using uninitialized values because
prism strings are not null terminated. This can be seen in the Valgrind
output:

    ==834710== Conditional jump or move depends on uninitialised value(s)
    ==834710==    at 0x5DA010: pm_regexp_parse_range_quantifier (regexp.c:163)
    ==834710==    by 0x5DA010: pm_regexp_parse_quantifier (regexp.c:243)
    ==834710==    by 0x5DAD69: pm_regexp_parse_expression (regexp.c:738)
    ==834710==    by 0x5DAD69: pm_regexp_parse_pattern (regexp.c:761)
    ==834710==    by 0x5DAD69: pm_regexp_parse (regexp.c:773)
    ==834710==    by 0x5A2EE7: parse_regular_expression_named_captures (prism.c:20886)
    ==834710==    by 0x5A2EE7: parse_expression_infix (prism.c:21388)
    ==834710==    by 0x5A5FA5: parse_expression (prism.c:21804)
    ==834710==    by 0x5A64F3: parse_statements (prism.c:13858)
    ==834710==    by 0x5A9730: parse_program (prism.c:22011)
    ==834710==    by 0x576F0D: parse_input_success_p (extension.c:1062)
    ==834710==    by 0x576F0D: parse_success_p (extension.c:1084)

This commit adds checks for the end of the string to
pm_regexp_parse_range_quantifier.

be6cbc23ef
2024-11-12 14:19:46 +00:00
Misaki Shioi
fee706d9dd
Allow Net::HTTP#request to raise Net::OpenTimeout (#12062)
with a TCPSoerver that is only listening
to avoid AssertionFailedError on Ubuntu.

---

The tests such as
`TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write`
expect to raise a `Net::WriteTimeout` due to a failure in writing to the server.

However, on Ubuntu environments,
the server immediately returns a "Connection Refused" in such cases.
The socket created with `TCPSocket.new` that supports HEv2 catches this immediately
and raises a `Net::OpenTimeout`.
As a result, these tests fail due to raising a different exception than expected.
This PR adds `Net::OpenTimeout` asexceptions to avoid these test failures.
2024-11-12 19:14:05 +09:00
John Hawthorn
8409edc497 Fix regex timeout double-free after stack_double
As of 10574857ce, it's possible to crash
on a double free due to `stk_alloc` AKA `msa->stack_p` being freed
twice, once at the end of match_at and a second time in `FREE_MATCH_ARG`
in the parent caller.

Fixes [Bug #20886]
2024-11-11 23:33:21 -08:00