erb 5.0.3 → 5.1.0

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: 335faf3ef112b23c4f6066554480a40426ae7dc1d036f018e33bbac13c881c18
4
- data.tar.gz: 341547a90647453d267fc035d0f7a2b6c05a617e958cafd45d07c4ee6b6b2ef2
3
+ metadata.gz: 90f0ce0edaaa7d86d9a02d7062cbf92113d69fc15abeea302b0372b2dac80964
4
+ data.tar.gz: 95b673abbc9477ed2dc09196bc2f06ce3c81a5cc8dc45612bffc897c8ef1d15f
5
5
  SHA512:
6
- metadata.gz: fd258645b17ca0e0045bdc3c2db4311221942be033b12da3c546022ebac4742fa31b157c448d274c5c7bdd222e396d364bb96abee179810724da44fd9d70c63f
7
- data.tar.gz: 81763b69563026a2b0ba3a926524aa10f0bd2cf439c22fac2b4368a31257ffd629ad1f2236eefeca30bbf733381fee28f54318b25dc43c5f24421a04cdc9d28d
6
+ metadata.gz: cfd7489d25b0662f8651dcafa1370403c97a7623a78b23835e963590585b4f5fe98c15d64973b3bde4187fcc1698d365ed10acced1f4d842ccdaee8b125363fe
7
+ data.tar.gz: 0fdfa9071e62c1c35b8104d17cf17e05c24ca91bb64faf22962adc11b03daec1d198ba96ad6165fe17fdd557a736e6dc15bbc90904f69480b67fefe25c0042cb
@@ -6,7 +6,7 @@ jobs:
6
6
  sync:
7
7
  name: Sync ruby
8
8
  runs-on: ubuntu-latest
9
- if: ${{ github.repository == 'ruby/erb' }}
9
+ if: ${{ github.repository_owner == 'ruby' }}
10
10
  steps:
11
11
  - uses: actions/checkout@v5
12
12
 
@@ -28,6 +28,6 @@ jobs:
28
28
  github_token: ${{ steps.app-token.outputs.token }}
29
29
  ref: master
30
30
  client_payload: |
31
- {"gem":"erb","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
31
+ {"gem":"${{ github.event.repository.name }}","before":"${{ github.event.before }}","after":"${{ github.event.after }}"}
32
32
  propagate_failure: true
33
33
  wait_interval: 10
data/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 5.1.0
4
+
5
+ * html_escape: Avoid buffer allocation for strings with no escapable character https://github.com/ruby/erb/pull/87
6
+
3
7
  ## 5.0.3
4
8
 
5
9
  * Update help of erb(1) [#85](https://github.com/ruby/erb/pull/85)
data/README.md CHANGED
@@ -1,21 +1,21 @@
1
- # \ERB (Embedded Ruby)
1
+ # ERB (Embedded Ruby)
2
2
 
3
- \ERB is an easy-to-use, but also very powerful, [template processor][template processor].
3
+ ERB is an easy-to-use, but also very powerful, [template processor][template processor].
4
4
 
5
- \ERB is commonly used to produce:
5
+ ERB is commonly used to produce:
6
6
 
7
7
  - Customized or personalized email messages.
8
8
  - Customized or personalized web pages.
9
9
  - Software code (in code-generating applications).
10
10
 
11
- Like method [sprintf][sprintf], \ERB can format run-time data into a string.
12
- \ERB, however, is *much more powerful*
11
+ Like method [sprintf][sprintf], ERB can format run-time data into a string.
12
+ ERB, however, is *much more powerful*
13
13
 
14
- ## How \ERB Works
14
+ ## How ERB Works
15
15
 
16
- Using \ERB, you can create a *template*: a plain-text string that has specially-formatted *tags*,
17
- then store it into an \ERB object;
18
- when \ERB produces _result_ string, it:
16
+ Using ERB, you can create a *template*: a plain-text string that has specially-formatted *tags*,
17
+ then store it into an ERB object;
18
+ when ERB produces _result_ string, it:
19
19
 
20
20
  - Inserts run-time-evaluated expressions into the result.
21
21
  - Executes snippets of Ruby code.
@@ -35,7 +35,7 @@ There are three types of tags:
35
35
  | Execution tag | <tt>'<% _ruby_code_ %>'</tt> | Execute <tt>_ruby_code_</tt>. | None. |
36
36
  | Comment tag | <tt>'<%# _comment_text_ %>'</tt> | None. | None. |
37
37
 
38
- These examples use `erb`, the \ERB command-line interface;
38
+ These examples use `erb`, the ERB command-line interface;
39
39
  each "echoes" a string template and pipes it to `erb` as input:
40
40
 
41
41
 
@@ -56,16 +56,16 @@ each "echoes" a string template and pipes it to `erb` as input:
56
56
  echo "<%# TODO: Fix this nonsense. %> Nonsense." | erb
57
57
  " Nonsense."
58
58
 
59
- ## How to Use \ERB
59
+ ## How to Use ERB
60
60
 
61
- You can use \ERB either:
61
+ You can use ERB either:
62
62
 
63
63
  - In a program: see class ERB.
64
64
  - From the command line: see [ERB Executable][erb executable].
65
65
 
66
66
  ## Installation
67
67
 
68
- \ERB is installed with Ruby, and so there's no further installation needed.
68
+ ERB is installed with Ruby, and so there's no further installation needed.
69
69
 
70
70
  ## Other Template Engines
71
71
 
@@ -77,7 +77,7 @@ Other popular template engines may be found in the [Ruby Toolbox][ruby toolbox].
77
77
 
78
78
  ## Code
79
79
 
80
- The \ERB source code is in GitHub project [ruby/erb][ruby/erb]/
80
+ The ERB source code is in GitHub project [ruby/erb][ruby/erb].
81
81
 
82
82
  ## Bugs
83
83
 
@@ -39,29 +39,44 @@ static VALUE
39
39
  optimized_escape_html(VALUE str)
40
40
  {
41
41
  VALUE vbuf;
42
- char *buf = ALLOCV_N(char, vbuf, escaped_length(str));
42
+ char *buf = NULL;
43
43
  const char *cstr = RSTRING_PTR(str);
44
44
  const char *end = cstr + RSTRING_LEN(str);
45
45
 
46
- char *dest = buf;
46
+ const char *segment_start = cstr;
47
+ char *dest = NULL;
47
48
  while (cstr < end) {
48
49
  const unsigned char c = *cstr++;
49
50
  uint8_t len = html_escape_table[c].len;
50
51
  if (len) {
52
+ uint16_t segment_len = cstr - segment_start - 1;
53
+ if (!buf) {
54
+ buf = ALLOCV_N(char, vbuf, escaped_length(str));
55
+ dest = buf;
56
+ }
57
+ if (segment_len) {
58
+ memcpy(dest, segment_start, segment_len);
59
+ dest += segment_len;
60
+ }
61
+ segment_start = cstr;
51
62
  memcpy(dest, html_escape_table[c].str, len);
52
63
  dest += len;
53
64
  }
54
- else {
55
- *dest++ = c;
65
+ }
66
+ if (buf) {
67
+ uint16_t segment_len = cstr - segment_start;
68
+ if (segment_len) {
69
+ memcpy(dest, segment_start, segment_len);
70
+ dest += segment_len;
56
71
  }
57
72
  }
58
73
 
59
74
  VALUE escaped = str;
60
- if (RSTRING_LEN(str) < (dest - buf)) {
75
+ if (buf) {
61
76
  escaped = rb_str_new(buf, dest - buf);
62
77
  preserve_original_state(str, escaped);
78
+ ALLOCV_END(vbuf);
63
79
  }
64
- ALLOCV_END(vbuf);
65
80
  return escaped;
66
81
  }
67
82
 
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.0.3'
4
+ VERSION = '5.1.0'
5
5
  end
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.0.3
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masatoshi SEKI