Skip to content

erb: fix Ractor::IsolationError - #156

Open
altruby wants to merge 1 commit into
ruby:masterfrom
altruby:patch1
Open

altruby wants to merge 1 commit into
ruby:masterfrom
altruby:patch1

Conversation

@altruby

@altruby altruby commented Dec 1, 2026

Copy link
Copy Markdown

This commit fixes a Ractor::IsolationError in
the following code:

Ractor.new do
  ERB::Util.escape_html("hello".encode("ISO-2022-JP"))
end.value

The CGI.escapeHTML method is used in this
codepath, and it is not Ractor-safe. The
fix avoids cgi.rb and converts the string
to UTF-8, escapes it, and then converts it
back to ISO-2022-JP before it is returned
to the caller.

When there is nothing to escape, the string
is returned as-is.

Another fix might be to make cgi.rb Ractor-safe,
or at least the method that erb uses.

This commit fixes a Ractor::IsolationError in
the following code:

```ruby
Ractor.new do
  ERB::Util.escape_html("hello".encode("ISO-2022-JP"))
end.value
```

The CGI.escapeHTML method is used in this
codepath, and it is not Ractor-safe. The
fix avoids cgi.rb and converts the string
to UTF-8, escapes it, and then converts it
back to ISO-2022-JP before it is returned
to the caller.

Another fix might be to make cgi.rb Ractor-safe,
or at least the method that erb uses.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant