[ruby/prism] Fix percent delimiter strings with crlfs
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.
[ruby/prism] Fix percent delimiter strings with crlfs
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 theopening 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
. Thenwe 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 [email protected]
Co-authored-by: eileencodes [email protected]
Co-authored-by: Kevin Newton [email protected]