temple 0.6.5 → 0.6.6

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
  SHA1:
3
- metadata.gz: ef295d25d34ef11abf1640d7240eedb8643e8107
4
- data.tar.gz: a721340521044f953fec55f2b75b0d467b2bdab4
3
+ metadata.gz: 7cc2dd0179a2556cfac6a0ec0e2e0ec5d7fbec30
4
+ data.tar.gz: 9369dee44f625d68dccded5ad36ed6716262b5aa
5
5
  SHA512:
6
- metadata.gz: e99dbeb234856873da69adb1460a123876f219e7c34d3c12bba379ee86fd60017cd56d17b5e5da6d2eff7d3e825135cfa57002232dc3e50d3676c59745b85dc9
7
- data.tar.gz: 22c4e6d503c7a3272ba39a153b3e7cf0ea92cb0a4937c5e6e05121ac5fe1efdd3d0ca7e3650d4a6633358542bcf4322ea27e0638e119f991db44bf58cf779810
6
+ metadata.gz: b876aee2589c3948760859554766f139a431c5927fc164a6841d922b449f90e96ba8227ecf7f4ab9c8a300aed4f2f315975149ee075eba1fe47a7dfe184d10c1
7
+ data.tar.gz: 41890f26bab5d9d3886e62b16f825e611821f81db03684cb2e3ee194d4f7727af5cd24121b678edd405013a831c4c7442833b7b6d472fb0a68eda6d1f09d76fe
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ master
2
+
3
+ * Use default encoding utf-8
4
+ * Escape also '
5
+ * Try to load escape_utils by default
6
+
1
7
  0.6.5
2
8
 
3
9
  * Added Filters::CodeMerger
@@ -4,7 +4,7 @@ module Temple
4
4
  #
5
5
  # @api public
6
6
  class Encoding < Parser
7
- define_options :encoding
7
+ define_options :encoding => 'utf-8'
8
8
 
9
9
  def call(s)
10
10
  if options[:encoding] && s.respond_to?(:encoding)
@@ -1,3 +1,9 @@
1
+ begin
2
+ require 'escape_utils'
3
+ rescue LoadError
4
+ # Loading EscapeUtils failed
5
+ end
6
+
1
7
  module Temple
2
8
  # @api public
3
9
  module Utils
@@ -20,30 +26,41 @@ module Temple
20
26
  def escape_html(html)
21
27
  EscapeUtils.escape_html(html.to_s, false)
22
28
  end
23
- elsif RUBY_VERSION > '1.9'
29
+ else
24
30
  # Used by escape_html
25
31
  # @api private
26
32
  ESCAPE_HTML = {
27
- '&' => '&amp;',
28
- '"' => '&quot;',
29
- '<' => '&lt;',
30
- '>' => '&gt;',
33
+ '&' => '&amp;',
34
+ '"' => '&quot;',
35
+ '\'' => '&#39;',
36
+ '<' => '&lt;',
37
+ '>' => '&gt;'
31
38
  }.freeze
32
39
 
33
- # Returns an escaped copy of `html`.
34
- #
35
- # @param html [String] The string to escape
36
- # @return [String] The escaped string
37
- def escape_html(html)
38
- html.to_s.gsub(/[&\"<>]/, ESCAPE_HTML)
40
+ if //.respond_to?(:encoding)
41
+ ESCAPE_HTML_PATTERN = Regexp.union(*ESCAPE_HTML.keys)
42
+ else
43
+ # On 1.8, there is a kcode = 'u' bug that allows for XSS otherwise
44
+ # TODO doesn't apply to jruby, so a better condition above might be preferable?
45
+ ESCAPE_HTML_PATTERN = /#{Regexp.union(*ESCAPE_HTML.keys)}/n
39
46
  end
40
- else
41
- # Returns an escaped copy of `html`.
42
- #
43
- # @param html [String] The string to escape
44
- # @return [String] The escaped string
45
- def escape_html(html)
46
- html.to_s.gsub(/&/n, '&amp;').gsub(/\"/n, '&quot;').gsub(/>/n, '&gt;').gsub(/</n, '&lt;')
47
+
48
+ if RUBY_VERSION > '1.9'
49
+ # Returns an escaped copy of `html`.
50
+ #
51
+ # @param html [String] The string to escape
52
+ # @return [String] The escaped string
53
+ def escape_html(html)
54
+ html.to_s.gsub(ESCAPE_HTML_PATTERN, ESCAPE_HTML)
55
+ end
56
+ else
57
+ # Returns an escaped copy of `html`.
58
+ #
59
+ # @param html [String] The string to escape
60
+ # @return [String] The escaped string
61
+ def escape_html(html)
62
+ html.to_s.gsub(ESCAPE_HTML_PATTERN) {|c| ESCAPE_HTML[c] }
63
+ end
47
64
  end
48
65
  end
49
66
 
@@ -1,3 +1,3 @@
1
1
  module Temple
2
- VERSION = '0.6.5'
2
+ VERSION = '0.6.6'
3
3
  end
@@ -16,6 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.license = 'MIT'
19
20
 
20
21
  # Tilt is only development dependency because most parts of Temple
21
22
  # can be used without it.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: temple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.5
4
+ version: 0.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Holm
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-20 00:00:00.000000000 Z
12
+ date: 2013-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: tilt
@@ -139,7 +139,8 @@ files:
139
139
  - test/test_hash.rb
140
140
  - test/test_utils.rb
141
141
  homepage: https://github.com/judofyr/temple
142
- licenses: []
142
+ licenses:
143
+ - MIT
143
144
  metadata: {}
144
145
  post_install_message:
145
146
  rdoc_options: []
@@ -157,7 +158,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  version: '0'
158
159
  requirements: []
159
160
  rubyforge_project:
160
- rubygems_version: 2.0.0
161
+ rubygems_version: 2.0.3
161
162
  signing_key:
162
163
  specification_version: 4
163
164
  summary: Template compilation framework in Ruby