inversion 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff47aba3a83fd9d627a25879f5dda61e904fcb60743fce28c45da4524c0c82f1
4
- data.tar.gz: 58f0c44113f5cb33e1070e5767f08a95368867b5205f45addf7d9436da5246e3
3
+ metadata.gz: de95b723b4e1d977b915f72d99659c4b73f6ca222afe91b4536c5e3e2c12bd73
4
+ data.tar.gz: 62b09f236668d37f6e33757d7cc7db174374ae5663ad42c6bd20aa9b55c40835
5
5
  SHA512:
6
- metadata.gz: 50af88a980608c0644d79f045a327ec145d257f299e19477f10379fcfe83148d07ec3d9bb93abd1bcfb3c06373772dfacfd3a2c44bd306ca39e5d25f16d3535c
7
- data.tar.gz: ff1ccfb839a8963c4a9713ced1861a37aade69455a1a31b309f27dd23626b68a4ba423c80a0ef67c8e788c240176d1a4ae147658097fe2303297d9f46e1180b7
6
+ metadata.gz: 1ad4969a736b028863e67d56e5b85b0ad887dcbba2313d9fe90f65f4a982216285c0dc988ba7852f23b157281395ad3dc43c78864fab233f82510d77a49bf284
7
+ data.tar.gz: 5c50d1f6636a0de6c65616a4996806d20bf50ba26d4da7295edf6d7d7e4eb6fdeb1bbff6b8148bd408137ceaf4a8ed465d87ba6e2fc4ba80f2df37d7d2224ef5
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,14 @@
1
+ = Release History for inversion
2
+
3
+ ---
4
+
5
+ == v1.3.1 [2020-09-29] Michael Granger <ged@faeriemud.org>
6
+
7
+ Improvements:
8
+
9
+ - Only use SafeYAML if it's already loaded
10
+ - Handle HTML encoding for uriencoding tag ourselves
11
+
1
12
 
2
13
  == v1.3.0 [2020-04-08] Mahlon E. Smith <mahlon@martini.nu>
3
14
 
@@ -26,7 +26,7 @@ module Inversion
26
26
  warn ">>> Inversion requires Ruby 2.4.0 or later. <<<" if RUBY_VERSION < '2.4.0'
27
27
 
28
28
  # Library version constant
29
- VERSION = '1.3.0'
29
+ VERSION = '1.3.1'
30
30
 
31
31
  # Version-control revision constant
32
32
  REVISION = %q$Revision$
@@ -130,6 +130,20 @@ module Inversion
130
130
  # The fallback escape format
131
131
  DEFAULT_ESCAPE_FORMAT = :none
132
132
 
133
+ # Unreserved characters from section 2.3 of RFC 3986
134
+ # ALPHA / DIGIT / "-" / "." / "_" / "~"
135
+ URI_ENCODED_CHARACTERS = /[^\w\-\.~]/
136
+
137
+
138
+ ### Inclusion callback; add Loggability if it isn't already present
139
+ def self::included( mod )
140
+ super
141
+ unless mod < Loggability
142
+ mod.extend( Loggability )
143
+ mod.log_to( :inversion )
144
+ end
145
+ end
146
+
133
147
 
134
148
  ### Escape the +output+ using the format specified by the given +render_state+'s config.
135
149
  def escape( output, render_state )
@@ -154,6 +168,17 @@ module Inversion
154
168
  gsub( />/, '&gt;' )
155
169
  end
156
170
 
171
+
172
+ ### Escape the given +output+ using the encoding specified in RFC3986 (URIs)
173
+ def escape_uri( output )
174
+ return output.to_s.gsub( URI_ENCODED_CHARACTERS ) do |m|
175
+ bytes = m[ 0 ].each_byte
176
+ bytes.inject( String.new ) do |buf, char|
177
+ buf + sprintf( '%%%0X', char )
178
+ end
179
+ end.force_encoding( Encoding::US_ASCII )
180
+ end
181
+
157
182
  end # Escaping
158
183
 
159
184
 
@@ -2,7 +2,8 @@
2
2
  # frozen_string_literal: true
3
3
  # vim: set noet nosta sw=4 ts=4 :
4
4
 
5
- require 'safe_yaml'
5
+ require 'yaml'
6
+
6
7
  require 'inversion/mixins'
7
8
  require 'inversion/template' unless defined?( Inversion::Template )
8
9
  require 'inversion/template/tag'
@@ -36,7 +37,12 @@ class Inversion::Template::ConfigTag < Inversion::Template::Tag
36
37
  raise Inversion::ParseError, 'Empty config settings' if
37
38
  body.nil? || body.strip.empty?
38
39
 
39
- opts = YAML.load( body, safe: true )
40
+ opts = if defined?( SafeYAML ) then
41
+ YAML.load( body, safe: true )
42
+ else
43
+ YAML.load( body )
44
+ end
45
+
40
46
  @options = symbolify_keys( opts )
41
47
 
42
48
  super
@@ -16,16 +16,14 @@ require 'inversion/template/attrtag'
16
16
  # <?uriencode foo.bar ?>
17
17
  #
18
18
  class Inversion::Template::UriencodeTag < Inversion::Template::AttrTag
19
+ include Inversion::Escaping
19
20
 
20
- # Unreserved characters from section 2.3 of RFC 3986
21
- # ALPHA / DIGIT / "-" / "." / "_" / "~"
22
- DEFAULT_ENCODED_CHARACTERS = /[^\w\-\.~]/
23
21
 
24
22
  ### Render the method chains against the attributes of the specified +render_state+
25
23
  ### and return them.
26
24
  def render( render_state )
27
25
  raw = super
28
- return URI.encode( raw.to_s, DEFAULT_ENCODED_CHARACTERS )
26
+ return escape_uri( raw.to_s )
29
27
  end
30
28
 
31
29
  end # class Inversion::Template::UriencodeTag
@@ -1,4 +1,4 @@
1
- <!-- $Id: unknown-tag.tmpl,v 1b4030ae65f3 2013/06/19 16:00:23 ged $ -->
1
+ <!-- $Id$ -->
2
2
  <?unknown This is an unknown tag type ?>
3
3
  <?comment Some stuff. ?>
4
4
  Stuff
@@ -108,7 +108,7 @@ describe Inversion, "mixins" do
108
108
  include Inversion::Escaping
109
109
 
110
110
  def render( state )
111
- return self.escape( "<something>", state )
111
+ return self.escape( "</something>", state )
112
112
  end
113
113
  end
114
114
  @obj = objclass.new
@@ -116,18 +116,28 @@ describe Inversion, "mixins" do
116
116
 
117
117
  it "adds configurable escaping to including classes" do
118
118
  render_state = Inversion::RenderState.new( {}, :escape_format => :html )
119
- expect( @obj.render( render_state ) ).to eq( "&lt;something&gt;" )
119
+ expect( @obj.render( render_state ) ).to eq( "&lt;/something&gt;" )
120
120
  end
121
121
 
122
122
  it "doesn't escape anything if escaping is disabled" do
123
123
  render_state = Inversion::RenderState.new( {}, :escape_format => nil )
124
- expect( @obj.render( render_state ) ).to eq( "<something>" )
124
+ expect( @obj.render( render_state ) ).to eq( "</something>" )
125
125
  end
126
126
 
127
127
  it "doesn't escape anything if escaping is set to ':none'" do
128
128
  render_state = Inversion::RenderState.new( {}, :escape_format => :none )
129
- expect( @obj.render( render_state ) ).to eq( "<something>" )
129
+ expect( @obj.render( render_state ) ).to eq( "</something>" )
130
130
  end
131
+
132
+ it "supports URI escaping" do
133
+ render_state = Inversion::RenderState.new( {}, :escape_format => :uri )
134
+
135
+ rval = @obj.render( render_state )
136
+
137
+ expect( rval.encoding ).to eq( Encoding::US_ASCII )
138
+ expect( rval ).to eq( "%3C%2Fsomething%3E" )
139
+ end
140
+
131
141
  end
132
142
 
133
143
 
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inversion
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
8
8
  - Mahlon E. Smith
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIENDCCApygAwIBAgIBATANBgkqhkiG9w0BAQsFADAiMSAwHgYDVQQDDBdtYWhs
15
- b24vREM9bWFydGluaS9EQz1udTAeFw0yMDAyMTkyMTU4NDBaFw0yMTAyMTgyMTU4
16
- NDBaMCIxIDAeBgNVBAMMF21haGxvbi9EQz1tYXJ0aW5pL0RDPW51MIIBojANBgkq
17
- hkiG9w0BAQEFAAOCAY8AMIIBigKCAYEA3cz7ILM8n+Y5nvz7mVRVqE8LusWdT8NX
18
- nlnETynDndenI+a2S3j22DR+U4ooGUjuCHE3iR1CVmTDGbxFfNRfmnC1AN9Hybat
19
- ewW+onvMBye7yfO0bJB5vkqaW5vd35rzquOffgBtJMo7rPRu6pX8RkL34Wnew4J7
20
- POooUcYbWSAO934HSCUC8wVm6b4v/ejVF1Lk44Dz45jtMqtR7KTAtpipdbTXAarO
21
- HQy3eVes/0oTqhk4CP50r1KP09nUHTn2lzVaCN9vmNE/Jwe0AuQ9ImvZXPpCsMMl
22
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xujpAFd
31
+ qpn3JRQY+oj7ZkoccL/IUiDpxQWeS3oOoz9qr2kVTp8R50InZimt79FqCl/1m66W
32
+ kdOuf+wM3DDx7Rt4IVNHrhGlyfMr7xjKW1Q3gll+pMN1DT6Ajx/t3JDSEg7BnnEW
33
+ r7AciSO6J4ApUdqyG+coLFlGdtgFTgRHv7ihbQtDI7Z/LV7A4Spn1j2PK3j0Omri
34
+ kSl1hPVigRytfgdVGiLXzvkkrkgj9EknCaj5UHbac7XvVBrljXj9hsnnqTANaKsg
35
+ jBZSA+N+xUTgUWpXjjwsLZjzJkhWATJWq+krNXcqpwXo6HsjmdUxoFMt63RBb+sI
36
+ XrxOxp8o0uOkU7FdLSGsyqJ2LzsR4obN
37
37
  -----END CERTIFICATE-----
38
- date: 2020-04-08 00:00:00.000000000 Z
38
+ date: 2020-09-29 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: highline
@@ -205,6 +205,20 @@ dependencies:
205
205
  - - "~>"
206
206
  - !ruby/object:Gem::Version
207
207
  version: '2.0'
208
+ - !ruby/object:Gem::Dependency
209
+ name: safe_yaml
210
+ requirement: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - "~>"
213
+ - !ruby/object:Gem::Version
214
+ version: '1.0'
215
+ type: :development
216
+ prerelease: false
217
+ version_requirements: !ruby/object:Gem::Requirement
218
+ requirements:
219
+ - - "~>"
220
+ - !ruby/object:Gem::Version
221
+ version: '1.0'
208
222
  description: Inversion is a templating system for Ruby. It uses the “Inversion of
209
223
  Control” principle to decouple the contents and structure of templates from the
210
224
  code that uses them, making it easier to separate concerns, keep your tests simple,
@@ -311,7 +325,7 @@ metadata:
311
325
  documentation_uri: http://deveiate.org/code/Inversion
312
326
  source_uri: https://hg.sr.ht/~ged/Inversion/browse
313
327
  bug_tracker_uri: https://todo.sr.ht/~ged/Inversion/browse
314
- post_install_message:
328
+ post_install_message:
315
329
  rdoc_options: []
316
330
  require_paths:
317
331
  - lib
@@ -326,8 +340,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
340
  - !ruby/object:Gem::Version
327
341
  version: '0'
328
342
  requirements: []
329
- rubygems_version: 3.0.6
330
- signing_key:
343
+ rubygems_version: 3.1.2
344
+ signing_key:
331
345
  specification_version: 4
332
346
  summary: Inversion is a templating system for Ruby.
333
347
  test_files: []
metadata.gz.sig CHANGED
Binary file