erb 5.1.1 → 6.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1107eb08f7e1247a41f60f23c64ad54768f22b9c16a13b806fa82778df35621
4
- data.tar.gz: 8d1fdcfe00522b65de3b9043146bca73dca8612deade1a0e702583e08a45d85e
3
+ metadata.gz: b25d5fdfe9fee1fe6ecfb1e2e065899b51e0c1c4db0ad2d77684234b68483660
4
+ data.tar.gz: cd8460dbde78e4a3989a45bc2f1ac355f8ab949d2f5b15e26fbe4f049da1458b
5
5
  SHA512:
6
- metadata.gz: bfa22f8482dd7f968fb5e3d01f35c5463d77a71abaa8e1ece2e42b94ea481c3143dc5c4d880d1eea017e61a0287a0c7d8f841afc2a76f5ef73c9ef18c8693a97
7
- data.tar.gz: 9418c4a72cfb531f7dcdf88e505110225311a61ce30ac8d64f8d85021fad6e1983e6097f8ac31b2ac61c9a3bb81be1ec924e3ea0888645e993e55ca3a10a10b5
6
+ metadata.gz: dc41315bc958e50efdc1db906e998e9a6808410381be3ec70ffb0f9330b5520c89a5652fa0cf3e605caa237f52c8c5b05c9435d2a77fd08806664fdf769c56a9
7
+ data.tar.gz: 9937928ce2742fe22dd16317ea011984046a227782ea71b50c57b8c2d00e41534ae9f548ca8d14d2dc2a87a0fd42367462a75b56ea9e8678783c86ad0d57827a
data/NEWS.md CHANGED
@@ -1,4 +1,33 @@
1
- # Change Log
1
+ # Changelog
2
+
3
+ ## 6.0.4
4
+
5
+ * Prohibit `def_method` on marshal-loaded ERB instances
6
+
7
+ ## 6.0.3
8
+
9
+ * Exclude some files from published gem https://github.com/ruby/erb/pull/108
10
+
11
+ ## 6.0.2
12
+
13
+ * Freeze `src` in `ERB#initialize` for Ractor compatibility https://github.com/ruby/erb/pull/105
14
+
15
+ ## 6.0.1
16
+
17
+ * Freeze `ERB::Compiler::TrimScanner::ERB_STAG` for Ractor compatibility
18
+
19
+ ## 6.0.0
20
+
21
+ * Remove `safe_level` and further positional arguments from `ERB.new`
22
+ * Remove deprecated constant `ERB::Revision`
23
+
24
+ ## 5.1.3
25
+
26
+ * Release v5.1.2 with trusted publishing for JRuby
27
+
28
+ ## 5.1.2
29
+
30
+ * Add `changelog_uri` to spec metadata https://github.com/ruby/erb/pull/89
2
31
 
3
32
  ## 5.1.1
4
33
 
data/README.md CHANGED
@@ -81,7 +81,7 @@ The ERB source code is in GitHub project [ruby/erb][ruby/erb].
81
81
 
82
82
  ## Bugs
83
83
 
84
- Bugs may be reported at [ERB Issues][erb issues].
84
+ Bugfixes may be filed at [ERB Pull Requests][erb pull requests].
85
85
 
86
86
  ## License
87
87
 
@@ -90,7 +90,7 @@ of the [2-Clause BSD License][2-clause bsd license].
90
90
 
91
91
  [2-clause bsd license]: https://opensource.org/licenses/BSD-2-Clause
92
92
  [erb executable]: rdoc-ref:erb_executable.md
93
- [erb issues]: https://github.com/ruby/erb/issues
93
+ [erb pull requests]: https://github.com/ruby/erb/pull
94
94
  [rdoc]: https://ruby.github.io/rdoc/
95
95
  [ruby/erb]: https://github.com/ruby/erb
96
96
  [ruby toolbox]: https://www.ruby-toolbox.com/categories/template_engines
data/erb.gemspec CHANGED
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.metadata['homepage_uri'] = spec.homepage
20
20
  spec.metadata['source_code_uri'] = spec.homepage
21
+ spec.metadata['changelog_uri'] = "https://github.com/ruby/erb/blob/v#{spec.version}/NEWS.md"
21
22
 
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ spec.files = Dir.chdir(__dir__) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|\.git|\.github)/}) }
24
25
  end
25
26
  spec.bindir = 'libexec'
26
27
  spec.executables = ['erb']
@@ -63,16 +63,13 @@ optimized_escape_html(VALUE str)
63
63
  dest += len;
64
64
  }
65
65
  }
66
+ VALUE escaped = str;
66
67
  if (buf) {
67
68
  size_t segment_len = cstr - segment_start;
68
69
  if (segment_len) {
69
70
  memcpy(dest, segment_start, segment_len);
70
71
  dest += segment_len;
71
72
  }
72
- }
73
-
74
- VALUE escaped = str;
75
- if (buf) {
76
73
  escaped = rb_str_new(buf, dest - buf);
77
74
  preserve_original_state(str, escaped);
78
75
  ALLOCV_END(vbuf);
data/lib/erb/compiler.rb CHANGED
@@ -225,7 +225,7 @@ class ERB::Compiler # :nodoc:
225
225
  end
226
226
  end
227
227
 
228
- ERB_STAG = %w(<%= <%# <%)
228
+ ERB_STAG = %w(<%= <%# <%).freeze
229
229
  def is_erb_stag?(s)
230
230
  ERB_STAG.member?(s)
231
231
  end
@@ -480,7 +480,6 @@ class ERB::Compiler # :nodoc:
480
480
  end
481
481
  }.new(caller(0)).c
482
482
  private_constant :WARNING_UPLEVEL
483
- # :startdoc:
484
483
 
485
484
  def warn_invalid_trim_mode(mode, uplevel:)
486
485
  warn "Invalid ERB trim mode: #{mode.inspect} (trim_mode: nil, 0, 1, 2, or String composed of '%' and/or '-', '>', '<>')", uplevel: uplevel + WARNING_UPLEVEL
data/lib/erb/util.rb CHANGED
@@ -2,14 +2,14 @@
2
2
 
3
3
  # Load CGI.escapeHTML and CGI.escapeURIComponent.
4
4
  # CRuby:
5
- # cgi.gem v0.1.0+ (Ruby 2.7-3.4) and Ruby 3.5+ stdlib have 'cgi/escape' and CGI.escapeHTML.
6
- # cgi.gem v0.3.3+ (Ruby 3.2-3.4) and Ruby 3.5+ stdlib have CGI.escapeURIComponent.
5
+ # cgi.gem v0.1.0+ (Ruby 2.7-3.4) and Ruby 4.0+ stdlib have 'cgi/escape' and CGI.escapeHTML.
6
+ # cgi.gem v0.3.3+ (Ruby 3.2-3.4) and Ruby 4.0+ stdlib have CGI.escapeURIComponent.
7
7
  # JRuby: cgi.gem has a Java extension 'cgi/escape'.
8
8
  # TruffleRuby: lib/truffle/cgi/escape.rb requires 'cgi/util'.
9
9
  require 'cgi/escape'
10
10
 
11
11
  # Load or define ERB::Escape#html_escape.
12
- # We don't build the C extention 'cgi/escape' for JRuby, TruffleRuby, and WASM.
12
+ # We don't build the C extension 'cgi/escape' for JRuby, TruffleRuby, and WASM.
13
13
  # miniruby (used by CRuby build scripts) also fails to load erb/escape.so.
14
14
  begin
15
15
  require 'erb/escape'
@@ -19,6 +19,7 @@ rescue LoadError
19
19
  # A subset of ERB::Util. Unlike ERB::Util#html_escape, we expect/hope
20
20
  # Rails will not monkey-patch ERB::Escape#html_escape.
21
21
  module ERB::Escape
22
+ # :stopdoc:
22
23
  def html_escape(s)
23
24
  CGI.escapeHTML(s.to_s)
24
25
  end
data/lib/erb/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  class ERB
3
3
  # The string \ERB version.
4
- VERSION = '5.1.1'
4
+ VERSION = '6.0.4'
5
5
  end
data/lib/erb.rb CHANGED
@@ -60,7 +60,7 @@ require 'erb/util'
60
60
  # \ERB supports tags of three kinds:
61
61
  #
62
62
  # - [Expression tags][expression tags]:
63
- # each begins with `'<%'`, ends with `'%>'`; contains a Ruby expression;
63
+ # each begins with `'<%='`, ends with `'%>'`; contains a Ruby expression;
64
64
  # in the result, the value of the expression replaces the entire tag:
65
65
  #
66
66
  # template = 'The magic word is <%= magic_word %>.'
@@ -77,7 +77,7 @@ require 'erb/util'
77
77
  # ERB.new('Today is <%= Date::DAYNAMES[Date.today.wday] %>.').result # => "Today is Monday."
78
78
  #
79
79
  # - [Execution tags][execution tags]:
80
- # each begins with `'<%='`, ends with `'%>'`; contains Ruby code to be executed:
80
+ # each begins with `'<%'`, ends with `'%>'`; contains Ruby code to be executed:
81
81
  #
82
82
  # template = '<% File.write("t.txt", "Some stuff.") %>'
83
83
  # ERB.new(template).result
@@ -467,7 +467,7 @@ require 'erb/util'
467
467
  # ```
468
468
  #
469
469
  # You can give `trim_mode: '>'` to suppress the trailing newline
470
- # for each line that ends with `'%<'` (regardless of its beginning):
470
+ # for each line that ends with `'%>'` (regardless of its beginning):
471
471
  #
472
472
  # ```
473
473
  # ERB.new(template, trim_mode: '>').result.lines.each {|line| puts line.inspect }
@@ -778,9 +778,6 @@ require 'erb/util'
778
778
  # [template processor]: https://en.wikipedia.org/wiki/Template_processor
779
779
  #
780
780
  class ERB
781
- Revision = '$Date:: $' # :nodoc: #'
782
- deprecate_constant :Revision
783
-
784
781
  # :markup: markdown
785
782
  #
786
783
  # :call-seq:
@@ -827,60 +824,21 @@ class ERB
827
824
  #
828
825
  # It's good practice to choose a variable name that begins with an underscore: `'_'`.
829
826
  #
830
- # <b>Backward Compatibility</b>
831
- #
832
- # The calling sequence given above -- which is the one you should use --
833
- # is a simplified version of the complete formal calling sequence,
834
- # which is:
835
- #
836
- # ```
837
- # ERB.new(template,
838
- # safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN,
839
- # trim_mode: nil, eoutvar: '_erbout')
840
- # ```
841
- #
842
- # The second, third, and fourth positional arguments (those in the second line above) are deprecated;
843
- # this method issues warnings if they are given.
844
- #
845
- # However, their values, if given, are handled thus:
846
- #
847
- # - `safe_level`: ignored.
848
- # - `legacy_trim_mode`: overrides keyword argument `trim_mode`.
849
- # - `legacy_eoutvar`: overrides keyword argument `eoutvar`.
850
- #
851
827
  # [blank line control]: rdoc-ref:ERB@Suppressing+Unwanted+Blank+Lines
852
828
  # [combine trim modes]: rdoc-ref:ERB@Combining+Trim+Modes
853
829
  # [newline control]: rdoc-ref:ERB@Suppressing+Unwanted+Newlines
854
830
  # [shorthand format]: rdoc-ref:ERB@Shorthand+Format+for+Execution+Tags
855
831
  #
856
- def initialize(str, safe_level=NOT_GIVEN, legacy_trim_mode=NOT_GIVEN, legacy_eoutvar=NOT_GIVEN, trim_mode: nil, eoutvar: '_erbout')
857
- # Complex initializer for $SAFE deprecation at [Feature #14256]. Use keyword arguments to pass trim_mode or eoutvar.
858
- if safe_level != NOT_GIVEN
859
- warn 'Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.', uplevel: 1
860
- end
861
- if legacy_trim_mode != NOT_GIVEN
862
- warn 'Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.', uplevel: 1
863
- trim_mode = legacy_trim_mode
864
- end
865
- if legacy_eoutvar != NOT_GIVEN
866
- warn 'Passing eoutvar with the 4th argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, eoutvar: ...) instead.', uplevel: 1
867
- eoutvar = legacy_eoutvar
868
- end
869
-
832
+ def initialize(str, trim_mode: nil, eoutvar: '_erbout')
870
833
  compiler = make_compiler(trim_mode)
871
834
  set_eoutvar(compiler, eoutvar)
872
835
  @src, @encoding, @frozen_string = *compiler.compile(str)
836
+ @src.freeze
873
837
  @filename = nil
874
838
  @lineno = 0
875
839
  @_init = self.class.singleton_class
876
840
  end
877
841
 
878
- # :markup: markdown
879
- #
880
- # Placeholder constant; used as default value for certain method arguments.
881
- NOT_GIVEN = defined?(Ractor) ? Ractor.make_shareable(Object.new) : Object.new
882
- private_constant :NOT_GIVEN
883
-
884
842
  # :markup: markdown
885
843
  #
886
844
  # :call-seq:
@@ -894,7 +852,6 @@ class ERB
894
852
  # # => #<ERB::Compiler:0x000001cff9467678 @insert_cmd="print", @percent=false, @post_cmd=[], @pre_cmd=[], @put_cmd="print", @trim_mode=nil>
895
853
  # ```
896
854
  #
897
-
898
855
  def make_compiler(trim_mode)
899
856
  ERB::Compiler.new(trim_mode)
900
857
  end
@@ -1130,6 +1087,9 @@ class ERB
1130
1087
  # ```
1131
1088
  #
1132
1089
  def def_method(mod, methodname, fname='(ERB)')
1090
+ unless @_init.equal?(self.class.singleton_class)
1091
+ raise ArgumentError, "not initialized"
1092
+ end
1133
1093
  src = self.src.sub(/^(?!#|$)/) {"def #{methodname}\n"} << "\nend\n"
1134
1094
  mod.module_eval do
1135
1095
  eval(src, binding, fname, -1)
@@ -1211,7 +1171,6 @@ class ERB
1211
1171
  # </html>
1212
1172
  # ```
1213
1173
  #
1214
- #
1215
1174
  def def_class(superklass=Object, methodname='result')
1216
1175
  cls = Class.new(superklass)
1217
1176
  def_method(cls, methodname, @filename || '(ERB)')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erb
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.1
4
+ version: 6.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masatoshi SEKI
@@ -21,13 +21,9 @@ extensions:
21
21
  extra_rdoc_files: []
22
22
  files:
23
23
  - ".document"
24
- - ".github/dependabot.yml"
25
- - ".github/workflows/dependabot_automerge.yml"
26
- - ".github/workflows/sync-ruby.yml"
27
- - ".github/workflows/test.yml"
28
24
  - ".gitignore"
29
25
  - ".rdoc_options"
30
- - BDSL
26
+ - BSDL
31
27
  - COPYING
32
28
  - Gemfile
33
29
  - LICENSE.txt
@@ -54,6 +50,7 @@ licenses:
54
50
  metadata:
55
51
  homepage_uri: https://github.com/ruby/erb
56
52
  source_code_uri: https://github.com/ruby/erb
53
+ changelog_uri: https://github.com/ruby/erb/blob/v6.0.4/NEWS.md
57
54
  rdoc_options: []
58
55
  require_paths:
59
56
  - lib
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: 'github-actions'
4
- directory: '/'
5
- schedule:
6
- interval: 'monthly'
@@ -1,30 +0,0 @@
1
- name: Dependabot auto-merge
2
- on:
3
- pull_request:
4
-
5
- permissions:
6
- contents: write
7
- pull-requests: write
8
-
9
- jobs:
10
- automerge:
11
- runs-on: ubuntu-latest
12
- if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ruby/erb'
13
- steps:
14
- - name: Dependabot metadata
15
- uses: dependabot/fetch-metadata@v2
16
- id: metadata
17
-
18
- - name: Wait for status checks
19
- uses: lewagon/wait-on-check-action@v1
20
- with:
21
- repo-token: ${{ secrets.GITHUB_TOKEN }}
22
- ref: ${{ github.event.pull_request.head.sha || github.sha }}
23
- check-regexp: 'build \(.*\)'
24
- wait-interval: 30
25
-
26
- - name: Auto-merge for Dependabot PRs
27
- run: gh pr merge --auto --rebase "$PR_URL"
28
- env:
29
- PR_URL: ${{ github.event.pull_request.html_url }}
30
- GITHUB_TOKEN: ${{ secrets.MATZBOT_DEPENDABOT_MERGE_TOKEN }}
@@ -1,33 +0,0 @@
1
- name: Sync ruby
2
- on:
3
- push:
4
- branches: [master]
5
- jobs:
6
- sync:
7
- name: Sync ruby
8
- runs-on: ubuntu-latest
9
- if: ${{ github.repository_owner == 'ruby' }}
10
- steps:
11
- - uses: actions/checkout@v5
12
-
13
- - name: Create GitHub App token
14
- id: app-token
15
- uses: actions/create-github-app-token@v2
16
- with:
17
- app-id: 2060836
18
- private-key: ${{ secrets.RUBY_SYNC_DEFAULT_GEMS_PRIVATE_KEY }}
19
- owner: ruby
20
- repositories: ruby
21
-
22
- - name: Sync to ruby/ruby
23
- uses: convictional/trigger-workflow-and-wait@v1.6.5
24
- with:
25
- owner: ruby
26
- repo: ruby
27
- workflow_file_name: sync_default_gems.yml
28
- github_token: ${{ steps.app-token.outputs.token }}
29
- ref: master
30
- client_payload: |
31
- {"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
32
- propagate_failure: true
33
- wait_interval: 10
@@ -1,36 +0,0 @@
1
- name: test
2
-
3
- on:
4
- push:
5
- branches: [master]
6
- pull_request:
7
- workflow_dispatch:
8
-
9
- jobs:
10
- ruby-versions:
11
- uses: ruby/actions/.github/workflows/ruby_versions.yml@master
12
- with:
13
- engine: cruby
14
- versions: '["jruby", "truffleruby-head"]'
15
-
16
- test:
17
- needs: ruby-versions
18
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
19
- strategy:
20
- matrix:
21
- ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
22
- os: [ubuntu-latest]
23
- fail-fast: false
24
- runs-on: ${{ matrix.os }}
25
- steps:
26
- - uses: actions/checkout@v5
27
- - name: Set up Ruby
28
- uses: ruby/setup-ruby@v1
29
- with:
30
- ruby-version: ${{ matrix.ruby }}
31
- bundler-cache: true
32
- - name: Run test
33
- run: bundle exec rake test
34
- - name: RDoc coverage
35
- run: |
36
- rdoc -C .
/data/{BDSL → BSDL} RENAMED
File without changes