loofah 2.7.0 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of loofah might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce7e800422f2b83325a3c37aeb81c5fcb7f2c6d76d9be1f5228f3d49077643b8
4
- data.tar.gz: 6f4a5303926248d42f4e375d59d8d92e60c7fb797762910dd027aa54d8875922
3
+ metadata.gz: 10f6e8ff06a760da3400cdf8660e6768cfc2e7bbcb34a3ae6aaadea5e29ff924
4
+ data.tar.gz: 7e0accdb26147612bd7da3abc8fa98a6fac850dbb7a0ee99d20375400de4b877
5
5
  SHA512:
6
- metadata.gz: 98570a9ed755a285a42b31c05b8f45413b77119162d190c199f2ea8624f1038cff8ce8532e4339e3747410c9ab8ca645b02f237975643d24b4ad3b447336a35a
7
- data.tar.gz: '020485b66a1cb57fe1359bfbeec912631a48b268bbeb754b2ff67fa237cbb840d8ad5e66ec8b64b36d869dcf6866bd3c30191e3596a6481fd9a9258b0f4f8d96'
6
+ metadata.gz: 11b0f4dcad5a9f38444e9eebd45cb09705e536468c901c03d792711133536812f8b0579533eb54a305311d5303fdd4cf510761a9a0d42d0af46bb153d3402a3c
7
+ data.tar.gz: d6032694eaaaddd47c02868ecb037dc2673b5ebd749a7d8846c2a55e13744f9455a66b41ec16a4cf3c4905e6019df3493972ec462cd04404365ebe202e15e211
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ### 2.9.0 / 2021-01-14
4
+
5
+ * Handle CSS functions in a CSS shorthand property (like `background`). [[#199](https://github.com/flavorjones/loofah/issues/199), [#200](https://github.com/flavorjones/loofah/issues/200)]
6
+
7
+
8
+ ### 2.8.0 / 2020-11-25
9
+
10
+ * Allow CSS properties `order`, `flex-direction`, `flex-grow`, `flex-wrap`, `flex-shrink`, `flex-flow`, `flex-basis`, `flex`, `justify-content`, `align-self`, `align-items`, and `align-content`. [[#197](https://github.com/flavorjones/loofah/issues/197)] (Thanks, [@miguelperez](https://github.com/miguelperez)!)
11
+
12
+
3
13
  ## 2.7.0 / 2020-08-26
4
14
 
5
15
  ### Features
data/README.md CHANGED
@@ -6,10 +6,9 @@
6
6
 
7
7
  ## Status
8
8
 
9
- |System|Status|
10
- |--|--|
11
- | Concourse CI | [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/loofah/jobs/ruby-2.5/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/loofah?groups=master) |
12
- | Code Climate | [![Code Climate](https://codeclimate.com/github/flavorjones/loofah.svg)](https://codeclimate.com/github/flavorjones/loofah) |
9
+ [![Concourse CI](https://ci.nokogiri.org/api/v1/teams/nokogiri-core/pipelines/loofah/jobs/ruby-2.5/badge)](https://ci.nokogiri.org/teams/nokogiri-core/pipelines/loofah?groups=master)
10
+ [![Code Climate](https://codeclimate.com/github/flavorjones/loofah.svg)](https://codeclimate.com/github/flavorjones/loofah)
11
+ [![Tidelift dependencies](https://tidelift.com/badges/package/rubygems/loofah)](https://tidelift.com/subscription/pkg/rubygems-loofah?utm_source=rubygems-loofah&utm_medium=referral&utm_campaign=readme)
13
12
 
14
13
 
15
14
  ## Description
@@ -301,6 +300,10 @@ And the mailing list is on Google Groups:
301
300
 
302
301
  And the IRC channel is \#loofah on freenode.
303
302
 
303
+ Consider subscribing to [Tidelift][tidelift] which provides license assurances and timely security notifications for your open source dependencies, including Loofah. [Tidelift][tidelift] subscriptions also help the Loofah maintainers fund our [automated testing](https://ci.nokogiri.org) which in turn allows us to ship releases, bugfixes, and security updates more often.
304
+
305
+ [tidelift]: https://tidelift.com/subscription/pkg/rubygems-loofah?utm_source=undefined&utm_medium=referral&utm_campaign=enterprise
306
+
304
307
 
305
308
  ## Security
306
309
 
@@ -3,21 +3,22 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__))) unless $LOAD_PATH.i
3
3
 
4
4
  require "nokogiri"
5
5
 
6
- require "loofah/metahelpers"
7
- require "loofah/elements"
6
+ require_relative "loofah/version"
7
+ require_relative "loofah/metahelpers"
8
+ require_relative "loofah/elements"
8
9
 
9
- require "loofah/html5/safelist"
10
- require "loofah/html5/libxml2_workarounds"
11
- require "loofah/html5/scrub"
10
+ require_relative "loofah/html5/safelist"
11
+ require_relative "loofah/html5/libxml2_workarounds"
12
+ require_relative "loofah/html5/scrub"
12
13
 
13
- require "loofah/scrubber"
14
- require "loofah/scrubbers"
14
+ require_relative "loofah/scrubber"
15
+ require_relative "loofah/scrubbers"
15
16
 
16
- require "loofah/instance_methods"
17
- require "loofah/xml/document"
18
- require "loofah/xml/document_fragment"
19
- require "loofah/html/document"
20
- require "loofah/html/document_fragment"
17
+ require_relative "loofah/instance_methods"
18
+ require_relative "loofah/xml/document"
19
+ require_relative "loofah/xml/document_fragment"
20
+ require_relative "loofah/html/document"
21
+ require_relative "loofah/html/document_fragment"
21
22
 
22
23
  # == Strings and IO Objects as Input
23
24
  #
@@ -28,9 +29,6 @@ require "loofah/html/document_fragment"
28
29
  # quantities of docs.
29
30
  #
30
31
  module Loofah
31
- # The version of Loofah you are using
32
- VERSION = "2.7.0"
33
-
34
32
  class << self
35
33
  # Shortcut for Loofah::HTML::Document.parse
36
34
  # This method accepts the same parameters as Nokogiri::HTML::Document.parse
@@ -549,6 +549,9 @@ module Loofah
549
549
 
550
550
  ACCEPTABLE_CSS_PROPERTIES = Set.new([
551
551
  "azimuth",
552
+ "align-content",
553
+ "align-items",
554
+ "align-self",
552
555
  "background-color",
553
556
  "border-bottom-color",
554
557
  "border-collapse",
@@ -562,6 +565,13 @@ module Loofah
562
565
  "direction",
563
566
  "display",
564
567
  "elevation",
568
+ "flex",
569
+ "flex-basis",
570
+ "flex-direction",
571
+ "flex-flow",
572
+ "flex-grow",
573
+ "flex-shrink",
574
+ "flex-wrap",
565
575
  "float",
566
576
  "font",
567
577
  "font-family",
@@ -570,11 +580,13 @@ module Loofah
570
580
  "font-variant",
571
581
  "font-weight",
572
582
  "height",
583
+ "justify-content",
573
584
  "letter-spacing",
574
585
  "line-height",
575
586
  "list-style",
576
587
  "list-style-type",
577
588
  "max-width",
589
+ "order",
578
590
  "overflow",
579
591
  "page-break-after",
580
592
  "page-break-before",
@@ -7,22 +7,22 @@ module Loofah
7
7
  module Scrub
8
8
  CONTROL_CHARACTERS = /[`\u0000-\u0020\u007f\u0080-\u0101]/
9
9
  CSS_KEYWORDISH = /\A(#[0-9a-fA-F]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|-?\d{0,3}\.?\d{0,10}(ch|cm|r?em|ex|in|lh|mm|pc|pt|px|Q|vmax|vmin|vw|vh|%|,|\))?)\z/
10
- CRASS_SEMICOLON = { :node => :semicolon, :raw => ";" }
10
+ CRASS_SEMICOLON = { node: :semicolon, raw: ";" }
11
11
  CSS_IMPORTANT = '!important'
12
12
 
13
13
  class << self
14
14
  def allowed_element?(element_name)
15
- ::Loofah::HTML5::SafeList::ALLOWED_ELEMENTS_WITH_LIBXML2.include? element_name
15
+ ::Loofah::HTML5::SafeList::ALLOWED_ELEMENTS_WITH_LIBXML2.include?(element_name)
16
16
  end
17
17
 
18
18
  # alternative implementation of the html5lib attribute scrubbing algorithm
19
19
  def scrub_attributes(node)
20
20
  node.attribute_nodes.each do |attr_node|
21
21
  attr_name = if attr_node.namespace
22
- "#{attr_node.namespace.prefix}:#{attr_node.node_name}"
23
- else
24
- attr_node.node_name
25
- end
22
+ "#{attr_node.namespace.prefix}:#{attr_node.node_name}"
23
+ else
24
+ attr_node.node_name
25
+ end
26
26
 
27
27
  if attr_name =~ /\Adata-[\w-]+\z/
28
28
  next
@@ -58,13 +58,13 @@ module Loofah
58
58
  end
59
59
  end
60
60
 
61
- scrub_css_attribute node
61
+ scrub_css_attribute(node)
62
62
 
63
63
  node.attribute_nodes.each do |attr_node|
64
64
  node.remove_attribute(attr_node.name) if attr_node.value !~ /[^[:space:]]/
65
65
  end
66
66
 
67
- force_correct_attribute_escaping! node
67
+ force_correct_attribute_escaping!(node)
68
68
  end
69
69
 
70
70
  def scrub_css_attribute(node)
@@ -73,33 +73,50 @@ module Loofah
73
73
  end
74
74
 
75
75
  def scrub_css(style)
76
- style_tree = Crass.parse_properties style
76
+ style_tree = Crass.parse_properties(style)
77
77
  sanitized_tree = []
78
78
 
79
79
  style_tree.each do |node|
80
80
  next unless node[:node] == :property
81
81
  next if node[:children].any? do |child|
82
- [:url, :bad_url].include?(child[:node]) || (child[:node] == :function && !SafeList::ALLOWED_CSS_FUNCTIONS.include?(child[:name].downcase))
82
+ [:url, :bad_url].include?(child[:node])
83
83
  end
84
+
84
85
  name = node[:name].downcase
85
- if SafeList::ALLOWED_CSS_PROPERTIES.include?(name) || SafeList::ALLOWED_SVG_PROPERTIES.include?(name)
86
- sanitized_tree << node << CRASS_SEMICOLON
87
- elsif SafeList::SHORTHAND_CSS_PROPERTIES.include?(name.split("-").first)
88
- value = node[:value].split.map do |keyword|
89
- if SafeList::ALLOWED_CSS_KEYWORDS.include?(keyword) || keyword =~ CSS_KEYWORDISH
86
+ next unless SafeList::ALLOWED_CSS_PROPERTIES.include?(name) ||
87
+ SafeList::ALLOWED_SVG_PROPERTIES.include?(name) ||
88
+ SafeList::SHORTHAND_CSS_PROPERTIES.include?(name.split("-").first)
89
+
90
+ value = node[:children].map do |child|
91
+ case child[:node]
92
+ when :whitespace
93
+ nil
94
+ when :string
95
+ nil
96
+ when :function
97
+ if SafeList::ALLOWED_CSS_FUNCTIONS.include?(child[:name].downcase)
98
+ Crass::Parser.stringify(child)
99
+ end
100
+ when :ident
101
+ keyword = child[:value]
102
+ if !SafeList::SHORTHAND_CSS_PROPERTIES.include?(name.split("-").first) ||
103
+ SafeList::ALLOWED_CSS_KEYWORDS.include?(keyword) ||
104
+ (keyword =~ CSS_KEYWORDISH)
90
105
  keyword
91
106
  end
92
- end.compact
93
- unless value.empty?
94
- value << CSS_IMPORTANT if node[:important]
95
- propstring = sprintf "%s:%s", name, value.join(" ")
96
- sanitized_node = Crass.parse_properties(propstring).first
97
- sanitized_tree << sanitized_node << CRASS_SEMICOLON
107
+ else
108
+ child[:raw]
98
109
  end
99
- end
110
+ end.compact
111
+
112
+ next if value.empty?
113
+ value << CSS_IMPORTANT if node[:important]
114
+ propstring = format("%s:%s", name, value.join(" "))
115
+ sanitized_node = Crass.parse_properties(propstring).first
116
+ sanitized_tree << sanitized_node << CRASS_SEMICOLON
100
117
  end
101
118
 
102
- Crass::Parser.stringify sanitized_tree
119
+ Crass::Parser.stringify(sanitized_tree)
103
120
  end
104
121
 
105
122
  #
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ module Loofah
3
+ # The version of Loofah you are using
4
+ VERSION = "2.9.0"
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loofah
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Dalessio
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-08-26 00:00:00.000000000 Z
12
+ date: 2021-01-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -45,28 +45,28 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '12.3'
48
+ version: '13.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '12.3'
55
+ version: '13.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '2.2'
62
+ version: '5.14'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '2.2'
69
+ version: '5.14'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rr
72
72
  requirement: !ruby/object:Gem::Requirement
@@ -87,112 +87,42 @@ dependencies:
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: 2.3.0
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: 2.3.0
98
- - !ruby/object:Gem::Dependency
99
- name: hoe-gemspec
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - "~>"
103
- - !ruby/object:Gem::Version
104
- version: '1.0'
105
- type: :development
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '1.0'
112
- - !ruby/object:Gem::Dependency
113
- name: hoe-debugging
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - "~>"
117
- - !ruby/object:Gem::Version
118
- version: '2.0'
119
- type: :development
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - "~>"
124
- - !ruby/object:Gem::Version
125
- version: '2.0'
126
- - !ruby/object:Gem::Dependency
127
- name: hoe-bundler
128
- requirement: !ruby/object:Gem::Requirement
129
- requirements:
130
- - - "~>"
131
- - !ruby/object:Gem::Version
132
- version: '1.5'
90
+ version: '2.2'
133
91
  type: :development
134
92
  prerelease: false
135
93
  version_requirements: !ruby/object:Gem::Requirement
136
94
  requirements:
137
95
  - - "~>"
138
96
  - !ruby/object:Gem::Version
139
- version: '1.5'
97
+ version: '2.2'
140
98
  - !ruby/object:Gem::Dependency
141
- name: hoe-git
99
+ name: concourse
142
100
  requirement: !ruby/object:Gem::Requirement
143
101
  requirements:
144
102
  - - "~>"
145
103
  - !ruby/object:Gem::Version
146
- version: '1.6'
104
+ version: '0.33'
147
105
  type: :development
148
106
  prerelease: false
149
107
  version_requirements: !ruby/object:Gem::Requirement
150
108
  requirements:
151
109
  - - "~>"
152
110
  - !ruby/object:Gem::Version
153
- version: '1.6'
111
+ version: '0.33'
154
112
  - !ruby/object:Gem::Dependency
155
- name: hoe-markdown
113
+ name: rubocop
156
114
  requirement: !ruby/object:Gem::Requirement
157
115
  requirements:
158
116
  - - "~>"
159
117
  - !ruby/object:Gem::Version
160
- version: '1.2'
118
+ version: '1.1'
161
119
  type: :development
162
120
  prerelease: false
163
121
  version_requirements: !ruby/object:Gem::Requirement
164
122
  requirements:
165
123
  - - "~>"
166
124
  - !ruby/object:Gem::Version
167
- version: '1.2'
168
- - !ruby/object:Gem::Dependency
169
- name: concourse
170
- requirement: !ruby/object:Gem::Requirement
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- version: 0.26.0
175
- type: :development
176
- prerelease: false
177
- version_requirements: !ruby/object:Gem::Requirement
178
- requirements:
179
- - - ">="
180
- - !ruby/object:Gem::Version
181
- version: 0.26.0
182
- - !ruby/object:Gem::Dependency
183
- name: rubocop
184
- requirement: !ruby/object:Gem::Requirement
185
- requirements:
186
- - - ">="
187
- - !ruby/object:Gem::Version
188
- version: 0.76.0
189
- type: :development
190
- prerelease: false
191
- version_requirements: !ruby/object:Gem::Requirement
192
- requirements:
193
- - - ">="
194
- - !ruby/object:Gem::Version
195
- version: 0.76.0
125
+ version: '1.1'
196
126
  - !ruby/object:Gem::Dependency
197
127
  name: rdoc
198
128
  requirement: !ruby/object:Gem::Requirement
@@ -214,19 +144,19 @@ dependencies:
214
144
  - !ruby/object:Gem::Version
215
145
  version: '7'
216
146
  - !ruby/object:Gem::Dependency
217
- name: hoe
147
+ name: hoe-markdown
218
148
  requirement: !ruby/object:Gem::Requirement
219
149
  requirements:
220
150
  - - "~>"
221
151
  - !ruby/object:Gem::Version
222
- version: '3.22'
152
+ version: '1.3'
223
153
  type: :development
224
154
  prerelease: false
225
155
  version_requirements: !ruby/object:Gem::Requirement
226
156
  requirements:
227
157
  - - "~>"
228
158
  - !ruby/object:Gem::Version
229
- version: '3.22'
159
+ version: '1.3'
230
160
  description: |-
231
161
  Loofah is a general library for manipulating and transforming HTML/XML documents and fragments, built on top of Nokogiri.
232
162
 
@@ -238,24 +168,12 @@ email:
238
168
  - bryan@brynary.com
239
169
  executables: []
240
170
  extensions: []
241
- extra_rdoc_files:
242
- - CHANGELOG.md
243
- - MIT-LICENSE.txt
244
- - Manifest.txt
245
- - README.md
246
- - SECURITY.md
171
+ extra_rdoc_files: []
247
172
  files:
248
173
  - CHANGELOG.md
249
- - Gemfile
250
174
  - MIT-LICENSE.txt
251
- - Manifest.txt
252
175
  - README.md
253
- - Rakefile
254
176
  - SECURITY.md
255
- - benchmark/benchmark.rb
256
- - benchmark/fragment.html
257
- - benchmark/helper.rb
258
- - benchmark/www.slashdot.com.html
259
177
  - lib/loofah.rb
260
178
  - lib/loofah/elements.rb
261
179
  - lib/loofah/helpers.rb
@@ -268,6 +186,7 @@ files:
268
186
  - lib/loofah/metahelpers.rb
269
187
  - lib/loofah/scrubber.rb
270
188
  - lib/loofah/scrubbers.rb
189
+ - lib/loofah/version.rb
271
190
  - lib/loofah/xml/document.rb
272
191
  - lib/loofah/xml/document_fragment.rb
273
192
  homepage: https://github.com/flavorjones/loofah
@@ -275,14 +194,12 @@ licenses:
275
194
  - MIT
276
195
  metadata:
277
196
  homepage_uri: https://github.com/flavorjones/loofah
197
+ source_code_uri: https://github.com/flavorjones/loofah
278
198
  bug_tracker_uri: https://github.com/flavorjones/loofah/issues
279
- documentation_uri: https://www.rubydoc.info/gems/loofah/
280
199
  changelog_uri: https://github.com/flavorjones/loofah/blob/master/CHANGELOG.md
281
- source_code_uri: https://github.com/flavorjones/loofah
200
+ documentation_uri: https://www.rubydoc.info/gems/loofah/
282
201
  post_install_message:
283
- rdoc_options:
284
- - "--main"
285
- - README.md
202
+ rdoc_options: []
286
203
  require_paths:
287
204
  - lib
288
205
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -296,7 +213,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
296
213
  - !ruby/object:Gem::Version
297
214
  version: '0'
298
215
  requirements: []
299
- rubygems_version: 3.1.2
216
+ rubygems_version: 3.1.4
300
217
  signing_key:
301
218
  specification_version: 4
302
219
  summary: Loofah is a general library for manipulating and transforming HTML/XML documents