[Ruby 3.2] Add test for no extra escaping in error messages#1340
Merged
eregon merged 1 commit intoruby:masterfrom Feb 4, 2026
Merged
[Ruby 3.2] Add test for no extra escaping in error messages#1340eregon merged 1 commit intoruby:masterfrom
eregon merged 1 commit intoruby:masterfrom
Conversation
eregon
reviewed
Feb 2, 2026
eregon
reviewed
Feb 2, 2026
command_line/error_message_spec.rb
Outdated
| end | ||
|
|
||
| it "is not modified with extra escaping of control characters and backslashes" do | ||
| out = ruby_exe('raise "\e[31mRed\x1b[0m error\\\message"', args: "2>&1", exit_status: 1) |
Contributor
Author
There was a problem hiding this comment.
Single-quoted string turns \\ into \, and we need two backslashes inside the double-quoted string, so this needs 3 or 4 backslashes to output 1.
Member
There was a problem hiding this comment.
Let's do 4 then, 3 is quite hard to figure out and feels hacky
Contributor
Author
There was a problem hiding this comment.
Done. Actually, there seems to be no spec for backslash escaping at all, at least in language/string_spec.rb? Regexp quoting is probably relevant, but it relies on this.
Member
There was a problem hiding this comment.
Right, though I suppose it's already pretty well tested directly in Prism as that's where most of that backslash handling happens (in string literals at least).
9226f3a to
ad917a9
Compare
Ruby no longer escapes control characters and backslashes in an error message. [Feature #18367]
ad917a9 to
8877450
Compare
eregon
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From #1016