htmlentities 4.3.0 → 4.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ == 4.3.1 (2011-11-30)
2
+ * Fix bug when working with Rails 3/Ruby 1.8.7
3
+ * Make character encoding behaviour consistent in Ruby 1.9.2/1.9.3
4
+
1
5
  == 4.3.0 (2011-03-29)
2
6
  * Use Ruby 1.9's encoding support where available.
3
7
  * Deprecated HTMLEntities.encode_entities/decode_entities interface is now
@@ -7,7 +7,7 @@ class HTMLEntities
7
7
  end
8
8
 
9
9
  def decode(source)
10
- prepare(source).gsub(@entity_regexp) {
10
+ prepare(source).gsub(@entity_regexp){
11
11
  if $1 && codepoint = @map[$1]
12
12
  [codepoint].pack('U')
13
13
  elsif $2
@@ -13,9 +13,11 @@ class HTMLEntities
13
13
  end
14
14
 
15
15
  def encode(source)
16
- prepare(source).
17
- gsub(basic_entity_regexp){ encode_basic($&) }.
18
- gsub(extended_entity_regexp){ encode_extended($&) }
16
+ post_process(
17
+ prepare(source).
18
+ gsub(basic_entity_regexp){ |match| encode_basic(match) }.
19
+ gsub(extended_entity_regexp){ |match| encode_extended(match) }
20
+ )
19
21
  end
20
22
 
21
23
  private
@@ -24,21 +26,26 @@ class HTMLEntities
24
26
  def prepare(string) #:nodoc:
25
27
  string.to_s.encode(Encoding::UTF_8)
26
28
  end
29
+
30
+ def post_process(string)
31
+ if string.encoding != Encoding::ASCII && string.match(/\A[\x01-\x7F]*\z/)
32
+ string.encode(Encoding::ASCII)
33
+ else
34
+ string
35
+ end
36
+ end
27
37
  else
28
38
  def prepare(string) #:nodoc:
29
39
  string.to_s
30
40
  end
41
+
42
+ def post_process(string)
43
+ string
44
+ end
31
45
  end
32
46
 
33
47
  def basic_entity_regexp
34
- @basic_entity_regexp ||= (
35
- case @flavor
36
- when /^html/
37
- /[<>"&]/
38
- else
39
- /[<>'"&]/
40
- end
41
- )
48
+ @basic_entity_regexp ||= @flavor.match(/^html/) ? /[<>"&]/ : /[<>'"&]/
42
49
  end
43
50
 
44
51
  def extended_entity_regexp
@@ -2,7 +2,7 @@ class HTMLEntities
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 4
4
4
  MINOR = 3
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  $KCODE = 'u' unless "1.9".respond_to?(:encoding)
3
3
 
4
- require File.join(File.dirname(__FILE__), "performance")
4
+ require File.expand_path("../performance", __FILE__)
5
5
  require "benchmark"
6
6
 
7
7
  job = HTMLEntitiesJob.new
@@ -0,0 +1,15 @@
1
+ # encoding: UTF-8
2
+ require File.expand_path("../common", __FILE__)
3
+
4
+ if ENV["RUN_INTEROPERABILITY_TESTS"]
5
+ class HTMLEntities::InteroperabilityTest < Test::Unit::TestCase
6
+
7
+ def test_should_encode_active_support_safe_buffer
8
+ require 'active_support'
9
+ string = "<p>This is a test</p>"
10
+ buffer = ActiveSupport::SafeBuffer.new(string)
11
+ coder = HTMLEntities.new
12
+ assert_equal coder.encode(string, :named), coder.encode(buffer, :named)
13
+ end
14
+ end
15
+ end
metadata CHANGED
@@ -1,13 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmlentities
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
5
- prerelease: false
6
- segments:
7
- - 4
8
- - 3
9
- - 0
10
- version: 4.3.0
4
+ prerelease:
5
+ version: 4.3.1
11
6
  platform: ruby
12
7
  authors:
13
8
  - Paul Battley
@@ -15,8 +10,7 @@ autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
12
 
18
- date: 2011-03-29 00:00:00 +01:00
19
- default_executable:
13
+ date: 2011-11-30 00:00:00 Z
20
14
  dependencies: []
21
15
 
22
16
  description:
@@ -29,31 +23,31 @@ extra_rdoc_files:
29
23
  - History.txt
30
24
  - COPYING.txt
31
25
  files:
32
- - lib/htmlentities.rb
33
- - lib/htmlentities/flavors.rb
34
- - lib/htmlentities/version.rb
35
26
  - lib/htmlentities/encoder.rb
36
- - lib/htmlentities/mappings/expanded.rb
27
+ - lib/htmlentities/decoder.rb
37
28
  - lib/htmlentities/mappings/xhtml1.rb
29
+ - lib/htmlentities/mappings/expanded.rb
38
30
  - lib/htmlentities/mappings/html4.rb
39
- - lib/htmlentities/decoder.rb
40
- - test/decoding_test.rb
41
- - test/ruby_1_8_test.rb
42
- - test/xhtml1_test.rb
31
+ - lib/htmlentities/flavors.rb
32
+ - lib/htmlentities/version.rb
33
+ - lib/htmlentities.rb
43
34
  - test/html4_test.rb
35
+ - test/ruby_1_8_test.rb
36
+ - test/roundtrip_test.rb
44
37
  - test/encoding_test.rb
45
- - test/expanded_test.rb
46
- - test/ruby_1_9_test.rb
47
38
  - test/common.rb
48
- - test/roundtrip_test.rb
39
+ - test/xhtml1_test.rb
40
+ - test/decoding_test.rb
41
+ - test/ruby_1_9_test.rb
42
+ - test/expanded_test.rb
49
43
  - test/entities_test.rb
44
+ - test/interoperability_test.rb
45
+ - perf/benchmark.rb
50
46
  - perf/performance.rb
51
47
  - perf/profile.rb
52
- - perf/benchmark.rb
53
48
  - History.txt
54
49
  - COPYING.txt
55
- has_rdoc: true
56
- homepage: http://htmlentities.rubyforge.org/
50
+ homepage: https://github.com/threedaymonk/htmlentities
57
51
  licenses: []
58
52
 
59
53
  post_install_message:
@@ -66,33 +60,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
60
  requirements:
67
61
  - - ">="
68
62
  - !ruby/object:Gem::Version
69
- hash: 3
70
- segments:
71
- - 0
72
63
  version: "0"
73
64
  required_rubygems_version: !ruby/object:Gem::Requirement
74
65
  none: false
75
66
  requirements:
76
67
  - - ">="
77
68
  - !ruby/object:Gem::Version
78
- hash: 3
79
- segments:
80
- - 0
81
69
  version: "0"
82
70
  requirements: []
83
71
 
84
72
  rubyforge_project:
85
- rubygems_version: 1.3.7
73
+ rubygems_version: 1.8.11
86
74
  signing_key:
87
75
  specification_version: 3
88
76
  summary: A module for encoding and decoding (X)HTML entities.
89
77
  test_files:
90
- - test/decoding_test.rb
91
- - test/ruby_1_8_test.rb
92
- - test/xhtml1_test.rb
93
78
  - test/html4_test.rb
79
+ - test/ruby_1_8_test.rb
80
+ - test/roundtrip_test.rb
94
81
  - test/encoding_test.rb
95
- - test/expanded_test.rb
82
+ - test/xhtml1_test.rb
83
+ - test/decoding_test.rb
96
84
  - test/ruby_1_9_test.rb
97
- - test/roundtrip_test.rb
85
+ - test/expanded_test.rb
98
86
  - test/entities_test.rb
87
+ - test/interoperability_test.rb