Project

General

Profile

« Previous | Next » 

Revision 9fe6fd86

Added by eileencodes (Eileen Uchitelle) 6 months ago

[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.

Fixes: #3230

[Bug #20938]

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

Co-authored-by: John Hawthorn
Co-authored-by: eileencodes
Co-authored-by: Kevin Newton