552 Commits
Author SHA1 Message Date
Hiroshi SHIBATAandClaude Opus 5.5 5ed647fe15 Use rb_len_t for String and Array lengths in psych
The lengths that libyaml and libfyaml report as size_t are cast to rb_len_t instead of long when they become String lengths. It falls back to long on Ruby versions that do not define HAVE_RB_LEN_T.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 08:10:53 +09:00
Hiroshi SHIBATA 676b891714 [ruby/psych] v5.5.0
https://github.com/ruby/psych/commit/9b12bb3fb6
2026-08-21 01:51:28 +00:00
Nikita Vasilevsky 4b3d2563c5 [ruby/psych] Remove unused visitor helpers
merge_key was added empty in 2025502c while merge handling remained inline in revive_hash, and it has never been called. dump_list was added empty in 59ecddb while array dumping was implemented inline in visit_array_subclass, and it has never been called. Psych visitor dispatch only targets visit_* methods.

https://github.com/ruby/psych/commit/e61b6fd005
2026-08-21 01:19:30 +00:00
Hiroshi SHIBATAandClaude Opus 5 84a30ecc87 [ruby/psych] Reject a reentrant Psych::Parser#parse
The parser calls back into Ruby for every event, so a handler can call
#parse again on the same object. That reinitialised the parser and
re-pointed it at new input while the outer loop was still driving it,
which left the outer loop reading the inner document's freed buffer, or
resuming on a parser with no input at all and tripping libyaml's
read_handler assertion.

Psych::Exception is used so the caller can rescue it, and the in-use
flag is cleared with rb_ensure so a parser stays reusable afterwards.

https://github.com/ruby/psych/commit/5f2e37dc1c

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 01:05:51 +00:00
Hiroshi SHIBATAandClaude Opus 5 0d4afb71fc [ruby/psych] Stop the parse loop on an event that carries no type
Once libyaml has set stream_end_produced, every further
yaml_parser_parse succeeds with a zeroed event, so YAML_STREAM_END_EVENT
can no longer be reached and the loop calls handler#empty forever at
full CPU. A parser left in that state should terminate instead.

No test covers this directly because the loop only reaches it through a
reentrant parse, which the parser now rejects outright.

https://github.com/ruby/psych/commit/a667509a4a

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 01:05:51 +00:00
Hiroshi SHIBATAandClaude Opus 5 b996e6d3dc [ruby/psych] Propagate an exception raised in handler#event_location
Every case of the event switch overwrote the rb_protect state, so only
the second result was ever tested and the state from the event_location
call was dropped. The parse then returned normally with the exception
silently discarded.

https://github.com/ruby/psych/commit/186c3fa343

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-21 01:05:51 +00:00
Nobuyoshi Nakada 7d4461e162 [Misc #22206] Generate dependencies without compiler builds
Replace `tool/update-deps` with a Ruby source scanner so dependency
updates no longer require GNU make, a configured build, or compiler
preprocessor output.

Keep compact source mappings and scanner declarations in dependency
files, and expand complete rules into the build directory.  Avoid the
temporary fixture headers required by the compiler-driven prototype.

Use the generated rules from GNU make, BSD make, and NMake builds.
Support out-of-tree and read-only source trees, and retain expanded
dependencies shipped in release archives when baseruby is unavailable.
2026-07-23 00:04:47 +09:00
Peter Zhu 89a5a0a1de Update depend for psych
https://github.com/ruby/psych/pull/805 added files psych_emitter_fy.c and
psych_parser_fy.c so we need to update the depend file too.
2026-07-02 01:14:54 -04:00
Hiroshi SHIBATAandClaude Opus 4.8 5ef8b6ef81 [ruby/psych] Require libfyaml 0.9 and build it from source in CI
The libfyaml-dev package on Ubuntu is 0.8, which segfaults psych's
emitter, while 0.9.6 (used on macOS via Homebrew) passes the whole suite.
Build the same 0.9.6 release from source in the Linux CI job, and reject
libfyaml older than 0.9 in extconf so users get a clear error instead of
a runtime crash. Also drop an unused variable in set_canonical.

https://github.com/ruby/psych/commit/88ac4a0cc0

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:16 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 82ab14ecb0 [ruby/psych] Address Copilot review feedback on the libfyaml backend
Reject canonical output with NotImplementedError instead of silently
ignoring the request, and honor the implicit flag in start_sequence and
start_mapping so an implicit tag is not printed as a redundant verbose
tag. Relax the unquoted-boolean dump test to allow an optional document
end marker. Also correct the version docstrings and a stale comment
about how the parser collects diagnostics.

https://github.com/ruby/psych/commit/23f60daff1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:16 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 f230671ca0 [ruby/psych] Harden the libfyaml backend after code review
Mark the reconstructed SyntaxError message UTF-8 instead of US-ASCII, so
a diagnostic that embeds a multibyte snippet of the input does not raise
Encoding::CompatibilityError when concatenated with UTF-8. Add
RB_GC_GUARD for the anchor and tag strings in the emitter (matching the
existing guard on the scalar value) so their C pointers cannot dangle if
a GC runs inside fy_emit_event_create.

https://github.com/ruby/psych/commit/1c73f43df1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 49681874e0 [ruby/psych] Free tag-directive buffers on the error path in start_document
The xcalloc'd tag buffers leaked when StringValue, the tuple-length
check, or the emit raised mid-way. Wrap the work in rb_ensure so the
buffers are always freed, and keep the exported directive strings in a
Ruby array so the GC cannot reclaim them while their C pointers are in
use.

https://github.com/ruby/psych/commit/6fdede0177

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 e88db7ea80 [ruby/psych] Transcode UTF-16 IO input to UTF-8 on the libfyaml backend
libfyaml only consumes UTF-8, so a UTF-16 IO fed through the chunked
reader reached it as raw bytes and was rejected as invalid UTF-8. When
the IO's external encoding is UTF-16LE/BE, slurp the whole stream and
transcode it first; a 2-byte unit could otherwise straddle a read
boundary. Other non-UTF-8 encodings stay raw and libfyaml rejects them,
matching psych's UTF-8/UTF-16-only IO contract (Shift_JIS still raises).

https://github.com/ruby/psych/commit/4bd1343551

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 7a912af002 [ruby/psych] Match libyaml scalar emission on the libfyaml backend
Drop the tag when plain_implicit or quoted_implicit is set, matching how
libyaml omits a tag that the value resolves to on reload; otherwise nil
emitted as "!<tag:yaml.org,2002:null>" instead of an empty scalar. Honor
the plain hint when choosing the scalar style, and restore the Check_Type
guards on anchor and tag so non-string arguments raise TypeError.

https://github.com/ruby/psych/commit/ff15ddf399

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 0a66bb8735 [ruby/psych] Improve libfyaml parser fidelity and error reporting
Create a fresh parser per parse instead of reusing one via
fy_parser_reset(), which left default tag handles unset and rejected
bare ("---"-less) tag-led documents. Recover the real message and
position by switching the parser's own diagnostic object to collect
mode; creating a replacement diag crashes libfyaml 0.9.6. Drop the
spurious empty tag directive libfyaml reports.

https://github.com/ruby/psych/commit/d383361c23

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 4e225df5ed [ruby/psych] Resolve booleans per YAML 1.2 on the libfyaml backend
Scalar type resolution happens in ScalarScanner, not the C backend, so
swapping to libfyaml alone still resolved yes/no/on/off to booleans. Key
the boolean set on Psych::BACKEND so the libyaml default keeps the YAML
1.1 set while the experimental libfyaml backend follows 1.2.

https://github.com/ruby/psych/commit/b374869c59

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 ce089a3de1 [ruby/psych] Add experimental opt-in libfyaml backend
Built only with --enable-libfyaml; without the flag the default libyaml
backend is unchanged. The parser and emitter are reimplemented against
libfyaml's event API in separate translation units guarded by
PSYCH_USE_LIBFYAML, and the backend is not supported on Windows.

https://github.com/ruby/psych/commit/51f2493a2e

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-02 02:40:15 +00:00
Nobuyoshi Nakada 6df734ca4c [ruby/psych] Fix unused-but-set-global warnings in clang-23
https://github.com/ruby/psych/commit/7c1bd707a9
2026-06-25 10:26:32 +00:00
Vasil Nesterov 09383bfae7 [ruby/psych] Fix parsing of strings with tab-separated datetime
https://github.com/ruby/psych/commit/0ac39324a0
2026-06-12 03:56:20 +00:00
Hiroshi SHIBATAandClaude Fable 5 1d8688aa8d [ruby/psych] Use String#delete_prefix to strip the BOM
https://github.com/ruby/psych/commit/a1dcb86aed

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 02:53:39 +00:00
Hiroshi SHIBATAandClaude Fable 5 402049edb9 [ruby/psych] Strip the BOM from UTF-32 strings too
The C extension transcodes UTF-32 strings to UTF-8 with the BOM
preserved, so they were truncated the same way as UTF-8 input.

https://github.com/ruby/psych/commit/a141387024

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 02:53:39 +00:00
Hiroshi SHIBATAandClaude Fable 5 a8e45ba961 [ruby/psych] Restrict the BOM skip rescue to the seekability probe
If pos succeeded but the later seek failed, the rescue silently
discarded the bytes read to check for a BOM. Only the initial pos call
is expected to fail, for non-seekable IOs, before anything is consumed.

https://github.com/ruby/psych/commit/57f34ae625

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 02:53:39 +00:00
Hiroshi SHIBATAandClaude Fable 5 be5995286d [ruby/psych] Strip a leading byte order mark before parsing
libyaml only discounts the BOM when it detects the stream encoding by
itself. Psych passes the encoding explicitly whenever it is known, and
on that path libyaml counts the BOM as a first-line character, shifting
every token on the first line one column right and silently terminating
a block mapping at the second line.

https://github.com/ruby/psych/issues/331

https://github.com/ruby/psych/commit/924c15ed1f

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 02:53:39 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 422347ea26 [ruby/psych] Reject non-Array/String classes for their subclass tags
!ruby/array, !seq and !ruby/string carry the same exposure just fixed
for the hash tags: the loader allocated the named class and replaced its
contents without checking the class was actually an Array or String
subclass. Apply the same subclass check so a permitted unrelated class
can no longer be allocated and populated through these tags.

https://github.com/ruby/psych/commit/73f0131b13

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 00:04:14 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 527d56a5ac [ruby/psych] Reject non-Hash classes for hash-with-ivars tags
!ruby/hash-with-ivars, !ruby/hash and !map are only emitted for Hash
subclasses, but the loader allocated whatever class the tag named and
populated its ivars directly. That let a permitted non-Hash class be
instantiated with attacker-chosen ivars, bypassing its init_with
validation. Verify the resolved class is a Hash subclass before use.

https://github.com/ruby/psych/commit/b08a71012e

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 00:04:14 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 ea6ce35094 [ruby/psych] Route !ruby/encoding through the class loader
safe_load resolved !ruby/encoding directly via ::Encoding.find,
bypassing the permitted_classes check that !ruby/object:Encoding
already honors. Load it through the class loader so Encoding is only
deserialized when permitted.

https://github.com/ruby/psych/commit/f2e4b9d365

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 00:04:13 +00:00
Hiroshi SHIBATA a4031fcacb [ruby/psych] v5.4.0
https://github.com/ruby/psych/commit/f7066d8f5e
2026-06-02 06:12:02 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 14bc2930e1 [ruby/psych] Round the io_reader clamp down to a character boundary
Clamping the over-read at exactly the requested size could split a
multibyte character, since the string an IO returns may carry a
non-binary encoding. Round the cut down to the last character boundary
at or before the size so the bytes handed to libyaml are always whole
characters.

https://github.com/ruby/psych/commit/6201ae17c1

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 02:10:54 +00:00
Hiroshi SHIBATAandClaude Opus 4.8 770ccaa6fb [ruby/psych] Clamp io_reader copy to libyaml's buffer size
io_reader trusted IO#read to honour its size argument and copied
RSTRING_LEN(string) bytes into libyaml's fixed-capacity buffer. An
IO-like object whose #read over-returns wrote past the buffer end, a
heap out-of-bounds write reachable from Psych.load/safe_load/parse.
Clamp the copied length to the requested size.

https://github.com/ruby/psych/commit/99ecd94560

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 02:10:54 +00:00
Charles Oliver Nutter d2f7a19fe1 [ruby/psych] Revert "Update SnakeYAML-Engine to 3.0.1"
This reverts commit https://github.com/ruby/psych/commit/599f89d0fd42.

https://github.com/ruby/psych/commit/97973490f4
2026-03-23 21:02:59 +00:00
Charles Oliver Nutter 8da2777ddc [ruby/psych] Update SnakeYAML-Engine to 3.0.1
There are two CVEs in Guava, which is a test-scoped dependency of
this library. Guava is not shipped with the library so these CVEs
do not affect users, but the dependency may trigger security tools.
We update to avoid this false positive.

https://www.cve.org/CVERecord?id=CVE-2023-2976

https://www.cve.org/CVERecord?id=CVE-2020-8908

Fixes ruby/psych#780

https://github.com/ruby/psych/commit/599f89d0fd
2026-03-15 23:13:57 +00:00
Hiroshi SHIBATA 8850807eb1 [ruby/psych] v5.3.1
https://github.com/ruby/psych/commit/8345af9ffb
2025-12-17 15:47:43 +09:00
nick evans b3f0fb5618 [ruby/psych] Replace C extension with Data#initialize bind_call
https://github.com/ruby/psych/commit/6a826693ba
2025-12-15 22:48:40 +00:00
kares 4ab45e8f0c [ruby/psych] bump snakeyaml-engine to 2.10 (jruby)
https://github.com/ruby/psych/commit/506bf75ab2
2025-12-11 15:01:04 +00:00
Hiroshi SHIBATA df4fc0f7fc [ruby/psych] v5.3.0
https://github.com/ruby/psych/commit/d8053b0d16
2025-12-10 05:08:04 +00:00
Étienne Barrié 65dbd571c1 [ruby/psych] Use Node#to_ruby parse_symbols option
https://github.com/ruby/psych/commit/907fd4fa97
2025-12-05 17:14:30 +00:00
Caleb Stewart 0e7e6858e3 [ruby/psych] Add option to disable symbol parsing
https://github.com/ruby/psych/commit/4e9d08c285
2025-12-04 00:42:17 +00:00
Rune Philosof 8f7d821dba [ruby/psych] Remove y Object extension in IRB
Fixes: ruby#685

This feature can easily break how you use other gems like factory_bot or prawn.

https://github.com/ruby/psych/pull/747#issuecomment-3413139525
> But I kind of think we should leave `psych/y` around. If people really want to use it they could require the file.

If you miss the function in Kernel, you can require it interactively or add it to `.irbrc`:
```ruby
require 'psych/y'
```

https://github.com/ruby/psych/commit/f1610b3f05
2025-12-04 00:40:11 +00:00
Benoit Daloze 3aa674ad99 [ruby/psych] Properly set the message of Exceptions on TruffleRuby
* From https://github.com/truffleruby/truffleruby/commit/1f81db82d2969ff7c5de0dacdecb38252664f42c

https://github.com/ruby/psych/commit/dbabe7aac6
2025-12-02 17:27:38 +00:00
Benoit Daloze d3907245d7 [ruby/psych] Fix usage of rb_struct_initialize() to pass an Array of members values and not a Hash
* rb_struct_initialize() does not accept a Hash, and it's very brittle
  to pass `[{...}]` and to rely on that C function using rb_keyword_given_p().
  It basically worked accidentally, by having **members in the caller of the caller.
  Such logic when Struct#initialize is defined in Ruby (as in TruffleRuby) is basically impossible to implement,
  because it's incorrectly treating positional arguments as keyword arguments.
* rb_struct_initialize() is used in CRuby to set members of Data instances in marshal.c (there is no rb_data_initialize() yet).
  There, the code passes an Array of members values for Data (and for Struct which are not `keyword_init: true`):
  https://github.com/ruby/ruby/blob/48c7f349f68846e10d60ae77ad299a38ee014479/marshal.c#L2150-L2176
  So we should do the same in psych.
* Rename to init_data since it's only used for Data.
* See https://github.com/ruby/psych/pull/692#discussion_r2483947279.

https://github.com/ruby/psych/commit/3550148378
2025-12-02 17:27:38 +00:00
Yasuo Honda c07b2329ed [ruby/psych] Replace Ruby 3.5 with Ruby 4.0
This commit updates the Ruby version to follow the commit in Ruby master branch.
https://github.com/ruby/ruby/commit/6d81969b475262aba251e99b518181bdf7c5a523

https://github.com/ruby/psych/commit/971b7de078
2025-11-11 21:05:11 +00:00
Étienne Barrié 6cd970b428 [ruby/psych] Remove warning by not calling find_library after pkg_config
If pkg_config returns a truthy value, it found the library and added it
to the global values for the Makefile.

Calling `find_library` after a successful `pkg_config` causes -lyaml to
appear twice in the LIBS variable in the resulting Makefile, and causes
ld on macOS to emit a warning:

    $ bundle exec rake compile 2>&1 | grep warning
    ld: warning: ignoring duplicate libraries: '-lyaml'

https://github.com/ruby/psych/commit/cb5e3d465c
2025-09-24 05:55:26 +00:00
Jeremy Evans 0b23a8db60 Update dependencies for addition of set.h to public headers 2025-07-11 15:24:23 +09:00
Aaron Patterson 957473d87f [ruby/psych] Bump version for release
https://github.com/ruby/psych/commit/b9dec9f811
2025-05-12 16:21:41 +00:00
Earlopain 0c94ae048a [ruby/psych] Fix dumping StringIO (and potentially others) on Ruby <= 2.7
In Ruby < 3.0, the superclass of StringIO was actually already `Data`,
but it doesn't have the expected shape. So, on these earlier versions it errors:
> NoMethodError: undefined method `members' for #<StringIO:0x00005641dd5f2880>
>    vendor/bundle/ruby/2.6.0/gems/psych-5.2.5/lib/psych/visitors/yaml_tree.rb:170:in `visit_Data'

This test doesn't fail on 2.7, presumably because it can pull in a newer `stringio` version.

https://github.com/ruby/psych/commit/0f40f56268
2025-05-12 16:19:38 +00:00
Aaron Patterson 58c008e68f [ruby/psych] Bump version for release
https://github.com/ruby/psych/commit/dbf9e36583
2025-05-09 22:12:47 +00:00
OrenGitHub ae299cc9cd [ruby/psych] add first test for safe load stream
https://github.com/ruby/psych/commit/336553b412
2025-05-09 17:53:17 +00:00
OrenGitHub f0e2a41d4b [ruby/psych] fixed bugs from testing
https://github.com/ruby/psych/commit/e954f96639
2025-05-09 17:53:17 +00:00
OrenGitHub d69319304f [ruby/psych] Add safe version for load_stream
https://github.com/ruby/psych/commit/30a2a5ee94
2025-05-09 17:53:17 +00:00
Jean Boussier 1f2a9dc2a9 [ruby/psych] Refine Ruby 3.5 Set support.
Use feature testing to detect native Set,
and don't rely on `Set#to_h` which wasn't intended
as a public method.

https://github.com/ruby/psych/commit/d58cff11af
2025-05-08 18:03:04 +09:00