<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/prism/percent_delimiter_string_test.rb, branch v4.0.3</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>[ruby/prism] Decode %r like % strings</title>
<updated>2024-12-12T00:42:44+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2024-12-11T23:54:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9181e8bc87dd167673bc6cfc255c7003e4c6b05e'/>
<id>9181e8bc87dd167673bc6cfc255c7003e4c6b05e</id>
<content type='text'>
%r regular expressions need to be decoded like strings.  This commit
fixes %r decoding so it works like strings.

https://github.com/ruby/prism/commit/85bfd9c0cd
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
%r regular expressions need to be decoded like strings.  This commit
fixes %r decoding so it works like strings.

https://github.com/ruby/prism/commit/85bfd9c0cd
</pre>
</div>
</content>
</entry>
<entry>
<title>[ruby/prism] Fix percent delimiter strings with crlfs</title>
<updated>2024-12-11T23:06:32+00:00</updated>
<author>
<name>eileencodes</name>
<email>eileencodes@gmail.com</email>
</author>
<published>2024-12-05T18:56:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9fe6fd86936ead769fe983feb5461ca4f192f16e'/>
<id>9fe6fd86936ead769fe983feb5461ca4f192f16e</id>
<content type='text'>
parse.y treats CRLF as a LF and basically "normalizes" them before
parsing.  That means a string like `%\nfoo\r\n` is actually treated as
`%\nfoo\n` for the purposes of parsing.  This happens on both the
opening side of the percent string as well as on the closing side.  So
for example `%\r\nfoo\n` must be treated as `%\nfoo\n`.

To handle this in Prism, when we start a % string, we check if it starts
with `\r\n`, and then consider the terminator to actually be `\n`.  Then
we check if there are `\r\n` as we lex the string and treat those as
`\n`, but only in the case the start was a `\n`.

Fixes: #3230

[Bug #20938]

https://github.com/ruby/prism/commit/e573ceaad6

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
Co-authored-by: eileencodes &lt;eileencodes@gmail.com&gt;
Co-authored-by: Kevin Newton &lt;kddnewton@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
parse.y treats CRLF as a LF and basically "normalizes" them before
parsing.  That means a string like `%\nfoo\r\n` is actually treated as
`%\nfoo\n` for the purposes of parsing.  This happens on both the
opening side of the percent string as well as on the closing side.  So
for example `%\r\nfoo\n` must be treated as `%\nfoo\n`.

To handle this in Prism, when we start a % string, we check if it starts
with `\r\n`, and then consider the terminator to actually be `\n`.  Then
we check if there are `\r\n` as we lex the string and treat those as
`\n`, but only in the case the start was a `\n`.

Fixes: #3230

[Bug #20938]

https://github.com/ruby/prism/commit/e573ceaad6

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
Co-authored-by: eileencodes &lt;eileencodes@gmail.com&gt;
Co-authored-by: Kevin Newton &lt;kddnewton@gmail.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
