|
| 1 | +From 8f1b08c6ca9321b14da49843fe12da495150f3cd Mon Sep 17 00:00:00 2001 |
| 2 | +From: Takashi Kokubun <takashikkbn@gmail.com> |
| 3 | +Date: Thu, 8 Dec 2022 22:36:35 -0800 |
| 4 | +Subject: [PATCH 1/7] [ruby/erb] Use a ruby-lang alias on spec.email |
| 5 | + |
| 6 | +https://github.com/ruby/erb/commit/39414f32a5 |
| 7 | +--- |
| 8 | + lib/erb.gemspec | 2 +- |
| 9 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 10 | + |
| 11 | +diff --git a/lib/erb.gemspec b/lib/erb.gemspec |
| 12 | +index d973cc10de..94a8fd5c3e 100644 |
| 13 | +--- a/lib/erb.gemspec |
| 14 | ++++ b/lib/erb.gemspec |
| 15 | +@@ -9,7 +9,7 @@ |
| 16 | + spec.name = 'erb' |
| 17 | + spec.version = ERB.const_get(:VERSION, false) |
| 18 | + spec.authors = ['Masatoshi SEKI', 'Takashi Kokubun'] |
| 19 | +- spec.email = ['seki@ruby-lang.org', 'takashikkbn@gmail.com'] |
| 20 | ++ spec.email = ['seki@ruby-lang.org', 'k0kubun@ruby-lang.org'] |
| 21 | + |
| 22 | + spec.summary = %q{An easy to use but powerful templating system for Ruby.} |
| 23 | + spec.description = %q{An easy to use but powerful templating system for Ruby.} |
| 24 | +-- |
| 25 | +2.54.0 |
| 26 | + |
| 27 | + |
| 28 | +From 07150fe3dd22423a862edad4dac56687a7de941d Mon Sep 17 00:00:00 2001 |
| 29 | +From: Nobuyoshi Nakada <nobu@ruby-lang.org> |
| 30 | +Date: Tue, 21 Mar 2023 19:00:18 +0900 |
| 31 | +Subject: [PATCH 2/7] [ruby/erb] [DOC] Use indented heredoc |
| 32 | + |
| 33 | +https://github.com/ruby/erb/commit/8ba8bb7acf |
| 34 | +--- |
| 35 | + lib/erb.rb | 4 ++-- |
| 36 | + 1 file changed, 2 insertions(+), 2 deletions(-) |
| 37 | + |
| 38 | +diff --git a/lib/erb.rb b/lib/erb.rb |
| 39 | +index 754419f819..bc1615d7da 100644 |
| 40 | +--- a/lib/erb.rb |
| 41 | ++++ b/lib/erb.rb |
| 42 | +@@ -307,11 +307,11 @@ def self.version |
| 43 | + # def build |
| 44 | + # b = binding |
| 45 | + # # create and run templates, filling member data variables |
| 46 | +- # ERB.new(<<-'END_PRODUCT'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@product").result b |
| 47 | ++ # ERB.new(<<~'END_PRODUCT', trim_mode: "", eoutvar: "@product").result b |
| 48 | + # <%= PRODUCT[:name] %> |
| 49 | + # <%= PRODUCT[:desc] %> |
| 50 | + # END_PRODUCT |
| 51 | +- # ERB.new(<<-'END_PRICE'.gsub(/^\s+/, ""), trim_mode: "", eoutvar: "@price").result b |
| 52 | ++ # ERB.new(<<~'END_PRICE', trim_mode: "", eoutvar: "@price").result b |
| 53 | + # <%= PRODUCT[:name] %> -- <%= PRODUCT[:cost] %> |
| 54 | + # <%= PRODUCT[:desc] %> |
| 55 | + # END_PRICE |
| 56 | +-- |
| 57 | +2.54.0 |
| 58 | + |
| 59 | + |
| 60 | +From 296693d52e43e9efa09383b626d6c8203e8e1435 Mon Sep 17 00:00:00 2001 |
| 61 | +From: Hiroshi SHIBATA <hsbt@ruby-lang.org> |
| 62 | +Date: Fri, 24 Mar 2023 13:39:03 +0900 |
| 63 | +Subject: [PATCH 3/7] [ruby/erb] Update test libraries from |
| 64 | + https://github.com/ruby/ruby/commit/b4e438d8aabaf4bba2b27f374c787543fae07c58 |
| 65 | + (https://github.com/ruby/erb/pull/48) |
| 66 | + |
| 67 | +https://github.com/ruby/erb/commit/3d3df5ce5c |
| 68 | +--- |
| 69 | + tool/lib/core_assertions.rb | 33 ++++++++++++--------------------- |
| 70 | + 1 file changed, 12 insertions(+), 21 deletions(-) |
| 71 | + |
| 72 | +diff --git a/tool/lib/core_assertions.rb b/tool/lib/core_assertions.rb |
| 73 | +index dea37b093e..c5a1d6ef3a 100644 |
| 74 | +--- a/tool/lib/core_assertions.rb |
| 75 | ++++ b/tool/lib/core_assertions.rb |
| 76 | +@@ -754,44 +754,35 @@ def assert_all_assertions_foreach(msg = nil, *keys, &block) |
| 77 | + end |
| 78 | + end |
| 79 | + end |
| 80 | +- |
| 81 | + # Expect +seq+ to respond to +first+ and +each+ methods, e.g., |
| 82 | + # Array, Range, Enumerator::ArithmeticSequence and other |
| 83 | + # Enumerable-s, and each elements should be size factors. |
| 84 | + # |
| 85 | + # :yield: each elements of +seq+. |
| 86 | + def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n}) |
| 87 | +- pend "No PERFORMANCE_CLOCK found" unless defined?(PERFORMANCE_CLOCK) |
| 88 | +- |
| 89 | +- # Timeout testing generally doesn't work when RJIT compilation happens. |
| 90 | +- rjit_enabled = defined?(RubyVM::RJIT) && RubyVM::RJIT.enabled? |
| 91 | +- measure = proc do |arg, message| |
| 92 | +- st = Process.clock_gettime(PERFORMANCE_CLOCK) |
| 93 | +- yield(*arg) |
| 94 | +- t = (Process.clock_gettime(PERFORMANCE_CLOCK) - st) |
| 95 | +- assert_operator 0, :<=, t, message unless rjit_enabled |
| 96 | +- t |
| 97 | +- end |
| 98 | +- |
| 99 | + first = seq.first |
| 100 | + *arg = pre.call(first) |
| 101 | + times = (0..(rehearsal || (2 * first))).map do |
| 102 | +- measure[arg, "rehearsal"].nonzero? |
| 103 | ++ st = Process.clock_gettime(Process::CLOCK_MONOTONIC) |
| 104 | ++ yield(*arg) |
| 105 | ++ t = (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st) |
| 106 | ++ assert_operator 0, :<=, t |
| 107 | ++ t.nonzero? |
| 108 | + end |
| 109 | + times.compact! |
| 110 | + tmin, tmax = times.minmax |
| 111 | +- |
| 112 | +- # safe_factor * tmax * rehearsal_time_variance_factor(equals to 1 when variance is small) |
| 113 | +- tbase = 10 * tmax * [(tmax / tmin) ** 2 / 4, 1].max |
| 114 | +- info = "(tmin: #{tmin}, tmax: #{tmax}, tbase: #{tbase})" |
| 115 | ++ tmax *= tmax / tmin |
| 116 | ++ tmax = 10**Math.log10(tmax).ceil |
| 117 | + |
| 118 | + seq.each do |i| |
| 119 | + next if i == first |
| 120 | +- t = tbase * i.fdiv(first) |
| 121 | ++ t = tmax * i.fdiv(first) |
| 122 | + *arg = pre.call(i) |
| 123 | +- message = "[#{i}]: in #{t}s #{info}" |
| 124 | ++ message = "[#{i}]: in #{t}s" |
| 125 | + Timeout.timeout(t, Timeout::Error, message) do |
| 126 | +- measure[arg, message] |
| 127 | ++ st = Process.clock_gettime(Process::CLOCK_MONOTONIC) |
| 128 | ++ yield(*arg) |
| 129 | ++ assert_operator (Process.clock_gettime(Process::CLOCK_MONOTONIC) - st), :<=, t, message |
| 130 | + end |
| 131 | + end |
| 132 | + end |
| 133 | +-- |
| 134 | +2.54.0 |
| 135 | + |
| 136 | + |
| 137 | +From 687b548b9d2ef4d0101576bad1639179708e42ac Mon Sep 17 00:00:00 2001 |
| 138 | +From: Josh Nichols <josh@technicalpickles.com> |
| 139 | +Date: Mon, 21 Aug 2023 21:41:06 -0700 |
| 140 | +Subject: [PATCH 4/7] [ruby/erb] Enable frozen_string_literal in all files |
| 141 | + (https://github.com/ruby/erb/pull/49) |
| 142 | + |
| 143 | +I was surprised to see erb show up when I was using memory_profiler on |
| 144 | +my app. ERB::Compiler#compile has a blank string literal, and it |
| 145 | +ended up allocating some 41532 blank strings for a relatively small surface |
| 146 | +area. |
| 147 | +--- |
| 148 | + lib/erb/compiler.rb | 1 + |
| 149 | + lib/erb/def_method.rb | 1 + |
| 150 | + lib/erb/util.rb | 1 + |
| 151 | + 3 files changed, 3 insertions(+) |
| 152 | + |
| 153 | +diff --git a/lib/erb/compiler.rb b/lib/erb/compiler.rb |
| 154 | +index 547d2c4c44..7096c8dcea 100644 |
| 155 | +--- a/lib/erb/compiler.rb |
| 156 | ++++ b/lib/erb/compiler.rb |
| 157 | +@@ -1,3 +1,4 @@ |
| 158 | ++# frozen_string_literal: true |
| 159 | + #-- |
| 160 | + # ERB::Compiler |
| 161 | + # |
| 162 | +diff --git a/lib/erb/def_method.rb b/lib/erb/def_method.rb |
| 163 | +index 17f9c0f9fa..aee989a926 100644 |
| 164 | +--- a/lib/erb/def_method.rb |
| 165 | ++++ b/lib/erb/def_method.rb |
| 166 | +@@ -1,3 +1,4 @@ |
| 167 | ++# frozen_string_literal: true |
| 168 | + #-- |
| 169 | + # ERB::DefMethod |
| 170 | + # |
| 171 | +diff --git a/lib/erb/util.rb b/lib/erb/util.rb |
| 172 | +index 0c1e7482a8..1d2a36275d 100644 |
| 173 | +--- a/lib/erb/util.rb |
| 174 | ++++ b/lib/erb/util.rb |
| 175 | +@@ -1,3 +1,4 @@ |
| 176 | ++# frozen_string_literal: true |
| 177 | + #-- |
| 178 | + # ERB::Escape |
| 179 | + # |
| 180 | +-- |
| 181 | +2.54.0 |
| 182 | + |
| 183 | + |
| 184 | +From ed308d0ca60e8bc5bf983f214c7ff025aed3a4db Mon Sep 17 00:00:00 2001 |
| 185 | +From: Takashi Kokubun <takashikkbn@gmail.com> |
| 186 | +Date: Mon, 21 Aug 2023 21:42:57 -0700 |
| 187 | +Subject: [PATCH 5/7] [ruby/erb] Version 4.0.3 |
| 188 | + |
| 189 | +https://github.com/ruby/erb/commit/c594f2fb86 |
| 190 | +--- |
| 191 | + lib/erb/version.rb | 2 +- |
| 192 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 193 | + |
| 194 | +diff --git a/lib/erb/version.rb b/lib/erb/version.rb |
| 195 | +index 38e1b76ff4..295fc5fa6f 100644 |
| 196 | +--- a/lib/erb/version.rb |
| 197 | ++++ b/lib/erb/version.rb |
| 198 | +@@ -1,5 +1,5 @@ |
| 199 | + # frozen_string_literal: true |
| 200 | + class ERB |
| 201 | +- VERSION = '4.0.2' |
| 202 | ++ VERSION = '4.0.3' |
| 203 | + private_constant :VERSION |
| 204 | + end |
| 205 | +-- |
| 206 | +2.54.0 |
| 207 | + |
| 208 | + |
| 209 | +From 076efa9313de7af237d1b5626a826fb7e30402e7 Mon Sep 17 00:00:00 2001 |
| 210 | +From: Takashi Kokubun <takashikkbn@gmail.com> |
| 211 | +Date: Tue, 21 Apr 2026 16:27:44 +0900 |
| 212 | +Subject: [PATCH 6/7] [ruby/erb] Prohibit def_method on marshal-loaded ERB |
| 213 | + instances |
| 214 | + |
| 215 | +Extends the @_init guard to def_method so that an ERB object created |
| 216 | +via Marshal.load (which bypasses initialize) raises ArgumentError |
| 217 | +instead of evaluating arbitrary source. def_module and def_class both |
| 218 | +delegate to def_method and are covered by the same check. |
| 219 | + |
| 220 | +https://github.com/ruby/erb/commit/ef61b591b2 |
| 221 | + |
| 222 | +Co-authored-by: Tristan Madani <TristanInSec@gmail.com> |
| 223 | +--- |
| 224 | + lib/erb.rb | 3 +++ |
| 225 | + test/erb/test_erb.rb | 27 +++++++++++++++++++++++++++ |
| 226 | + 2 files changed, 30 insertions(+) |
| 227 | + |
| 228 | +diff --git a/lib/erb.rb b/lib/erb.rb |
| 229 | +index bc1615d7da..a7317c0856 100644 |
| 230 | +--- a/lib/erb.rb |
| 231 | ++++ b/lib/erb.rb |
| 232 | +@@ -463,6 +463,9 @@ def new_toplevel(vars = nil) |
| 233 | + # erb.def_method(MyClass, 'render(arg1, arg2)', filename) |
| 234 | + # print MyClass.new.render('foo', 123) |
| 235 | + def def_method(mod, methodname, fname='(ERB)') |
| 236 | ++ unless @_init.equal?(self.class.singleton_class) |
| 237 | ++ raise ArgumentError, "not initialized" |
| 238 | ++ end |
| 239 | + src = self.src.sub(/^(?!#|$)/) {"def #{methodname}\n"} << "\nend\n" |
| 240 | + mod.module_eval do |
| 241 | + eval(src, binding, fname, -1) |
| 242 | +diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb |
| 243 | +index 555345a140..1266b64e41 100644 |
| 244 | +--- a/test/erb/test_erb.rb |
| 245 | ++++ b/test/erb/test_erb.rb |
| 246 | +@@ -714,6 +714,33 @@ def test_prohibited_marshal_load |
| 247 | + assert_raise(ArgumentError) {erb.result} |
| 248 | + end |
| 249 | + |
| 250 | ++ def test_prohibited_marshal_load_def_method |
| 251 | ++ erb = ERB.allocate |
| 252 | ++ erb.instance_variable_set(:@src, "") |
| 253 | ++ erb.instance_variable_set(:@lineno, 1) |
| 254 | ++ erb.instance_variable_set(:@_init, true) |
| 255 | ++ erb = Marshal.load(Marshal.dump(erb)) |
| 256 | ++ assert_raise(ArgumentError) {erb.def_method(Class.new, 'render')} |
| 257 | ++ end |
| 258 | ++ |
| 259 | ++ def test_prohibited_marshal_load_def_module |
| 260 | ++ erb = ERB.allocate |
| 261 | ++ erb.instance_variable_set(:@src, "") |
| 262 | ++ erb.instance_variable_set(:@lineno, 1) |
| 263 | ++ erb.instance_variable_set(:@_init, true) |
| 264 | ++ erb = Marshal.load(Marshal.dump(erb)) |
| 265 | ++ assert_raise(ArgumentError) {erb.def_module} |
| 266 | ++ end |
| 267 | ++ |
| 268 | ++ def test_prohibited_marshal_load_def_class |
| 269 | ++ erb = ERB.allocate |
| 270 | ++ erb.instance_variable_set(:@src, "") |
| 271 | ++ erb.instance_variable_set(:@lineno, 1) |
| 272 | ++ erb.instance_variable_set(:@_init, true) |
| 273 | ++ erb = Marshal.load(Marshal.dump(erb)) |
| 274 | ++ assert_raise(ArgumentError) {erb.def_class} |
| 275 | ++ end |
| 276 | ++ |
| 277 | + def test_multi_line_comment_lineno |
| 278 | + erb = ERB.new(<<~EOS) |
| 279 | + <%= __LINE__ %> |
| 280 | +-- |
| 281 | +2.54.0 |
| 282 | + |
| 283 | + |
| 284 | +From ca4b16b9966a85b083141edcfac4922d555ffe24 Mon Sep 17 00:00:00 2001 |
| 285 | +From: Takashi Kokubun <takashikkbn@gmail.com> |
| 286 | +Date: Tue, 21 Apr 2026 16:43:48 +0900 |
| 287 | +Subject: [PATCH 7/7] [ruby/erb] Version 4.0.3.1 |
| 288 | + |
| 289 | +https://github.com/ruby/erb/commit/b6be29fd0e |
| 290 | +--- |
| 291 | + lib/erb/version.rb | 2 +- |
| 292 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 293 | + |
| 294 | +diff --git a/lib/erb/version.rb b/lib/erb/version.rb |
| 295 | +index 295fc5fa6f..85e2a79def 100644 |
| 296 | +--- a/lib/erb/version.rb |
| 297 | ++++ b/lib/erb/version.rb |
| 298 | +@@ -1,5 +1,5 @@ |
| 299 | + # frozen_string_literal: true |
| 300 | + class ERB |
| 301 | +- VERSION = '4.0.3' |
| 302 | ++ VERSION = '4.0.3.1' |
| 303 | + private_constant :VERSION |
| 304 | + end |
| 305 | +-- |
| 306 | +2.54.0 |
| 307 | + |
0 commit comments