ruby-changes:47185
From: nagachika <ko1@a...>
Date: Mon, 10 Jul 2017 05:04:30 +0900 (JST)
Subject: [ruby-changes:47185] nagachika:r59300 (ruby_2_4): merge revision(s) 58823: [Backport #11464]
nagachika 2017-07-10 05:04:25 +0900 (Mon, 10 Jul 2017) New Revision: 59300 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59300 Log: merge revision(s) 58823: [Backport #11464] erb.rb: Allow trimming carriage return when trim_mode is "<>", for Windows environments. [Bug #11464] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/lib/erb.rb branches/ruby_2_4/test/erb/test_erb.rb branches/ruby_2_4/version.h Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 59299) +++ ruby_2_4/version.h (revision 59300) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.2" #define RUBY_RELEASE_DATE "2017-07-10" -#define RUBY_PATCHLEVEL 140 +#define RUBY_PATCHLEVEL 141 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 7 Index: ruby_2_4/test/erb/test_erb.rb =================================================================== --- ruby_2_4/test/erb/test_erb.rb (revision 59299) +++ ruby_2_4/test/erb/test_erb.rb (revision 59300) @@ -197,6 +197,11 @@ EOS https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/erb/test_erb.rb#L197 assert_equal(ans, erb.result) end + def test_trim_line2_with_carriage_return + erb = @erb.new("<% 3.times do %>\r\nline\r\n<% end %>\r\n", nil, '<>') + assert_equal("line\r\n" * 3, erb.result) + end + class Foo; end def test_def_class Index: ruby_2_4/lib/erb.rb =================================================================== --- ruby_2_4/lib/erb.rb (revision 59299) +++ ruby_2_4/lib/erb.rb (revision 59300) @@ -392,7 +392,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/erb.rb#L392 @scan_reg = /(.*?)(%>\n|#{(stags + etags).join('|')}|\n|\z)/m @scan_line = self.method(:trim_line1) elsif @trim_mode == '<>' - @scan_reg = /(.*?)(%>\n|#{(stags + etags).join('|')}|\n|\z)/m + @scan_reg = /(.*?)(%>\r?\n|#{(stags + etags).join('|')}|\n|\z)/m @scan_line = self.method(:trim_line2) elsif @trim_mode == '-' @scan_reg = /(.*?)(^[ \t]*<%\-|<%\-|-%>\n|-%>|#{(stags + etags).join('|')}|\z)/m @@ -457,7 +457,7 @@ class ERB https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/erb.rb#L457 tokens.each do |token| next if token.empty? head = token unless head - if token == "%>\n" + if token == "%>\n" || token == "%>\r\n" yield('%>') if is_erb_stag?(head) yield(:cr) Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 59299) +++ ruby_2_4 (revision 59300) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r58823 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/