html-pipeline 3.2.0 → 3.2.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: e8252d2015129b2ee071b6c094a773afecd796a75d0ab3d24aaa18b997be8f1f
4
- data.tar.gz: 3ace3231f84d7f5a82b4921d2ee600a4ae069440adb15e4ee527eda290b00637
3
+ metadata.gz: 7d505d0765630595363061d97d8f189a2712fc56b89371542a225d35421af386
4
+ data.tar.gz: 9d10f5ad3c9d39fe65d6e3b22cd59070997e5774353806affde0a957a52f5812
5
5
  SHA512:
6
- metadata.gz: be71b5590d6599b2a2c8d6dfdb98b27e61701a07bbc1a0aa14982459bfd65d8aec69228318834c939a6357dff03c982e739d2a39a83853e12016049e2ddd13e2
7
- data.tar.gz: b90b25b60016557c21eef5ee431c21890f5580589fabfafbe36e530ff3dc63cd3e3a83cf835c757cf8b7398e58c2f290096cf7ef8173177a27457b15871fe5e9
6
+ metadata.gz: 63b53387dfbb3bc7a9be29f0e6de9930daa773254dc885d0561b59a8d8ff50317ddabe62c364253b6da7142b3c4d169f72ce43f217ec50d18aee450513e88f13
7
+ data.tar.gz: 948027919009faea3009e0e222491aeae865db4875602a40bbf5a458f8b712f633b6e66d386e95acadbb129bcba33f63afdddbc89b73758cc1b544855eb5b227
@@ -1,4 +1,4 @@
1
- name: Release
1
+ name: Tag and Release
2
2
 
3
3
  on:
4
4
  workflow_dispatch:
@@ -7,13 +7,18 @@ on:
7
7
  - main
8
8
  paths:
9
9
  - "lib/html_pipeline/version.rb"
10
+ pull_request_target:
11
+ types:
12
+ - closed
10
13
 
11
14
  jobs:
12
15
  ruby:
13
16
  uses: yettoapp/actions/.github/workflows/ruby_gem_release.yml@main
14
17
  secrets:
15
18
  rubygems_api_key: ${{ secrets.RUBYGEMS_API_BOT_KEY }}
16
- gh_token: ${{ secrets.PUBLIC_PUSH_TO_PROTECTED_BRANCH }}
19
+ gh_token: ${{ secrets.GITHUB_TOKEN }}
17
20
  with:
18
21
  gem_name: html-pipeline
19
22
  version_filepath: lib/html_pipeline/version.rb
23
+ prepare: ${{ github.event_name == 'push' }}
24
+ release: ${{ github.event_name == 'workflow_dispatch' || ((github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release'))) }}
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # [v3.2.1] - 16-07-2024
2
+ ## What's Changed
3
+ * Update commonmarker requirement from ~> 1.0.0.pre7 to ~> 1.1.2 in the bundler-dependencies group by @dependabot in https://github.com/gjtorikian/html-pipeline/pull/404
4
+ * Remove superfluous sanitization by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/408
5
+
6
+
7
+ **Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.2.0...v3.2.1
8
+ ## [v3.2.0] - 30-04-2024
9
+ ## What's Changed
10
+ * Pass context along to every part of the pipeline by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/403
11
+
12
+
13
+ **Full Changelog**: https://github.com/gjtorikian/html-pipeline/compare/v3.1.1...v3.2.0
1
14
  ## [v3.1.1] - 09-04-2024
2
15
  ## What's Changed
3
16
  * Correct missing method implementation by @gjtorikian in https://github.com/gjtorikian/html-pipeline/pull/401
data/Gemfile CHANGED
@@ -25,7 +25,7 @@ group :development do
25
25
  end
26
26
 
27
27
  group :test do
28
- gem "commonmarker", "~> 1.0.0.pre7", require: false
28
+ gem "commonmarker", "~> 1.1.2", require: false
29
29
  gem "gemoji", "~> 4.1", require: false
30
30
  gem "gemojione", "~> 4.3", require: false
31
31
 
data/README.md CHANGED
@@ -171,9 +171,9 @@ The `ConvertFilter` takes text and turns it into HTML. `@text`, `@config`, and `
171
171
 
172
172
  ### Sanitization
173
173
 
174
- Because the web can be a scary place, HTML is automatically sanitized after the `ConvertFilter` runs and before the `NodeFilter`s are processed. This is to prevent malicious or unexpected input from entering the pipeline.
174
+ Because the web can be a scary place, **HTML is automatically sanitized** after the `ConvertFilter` runs and before the `NodeFilter`s are processed. This is to prevent malicious or unexpected input from entering the pipeline.
175
175
 
176
- The sanitization process takes a hash configuration of settings. See the [Selma](https://www.github.com/gjtorikian/selma) documentation for more information on how to configure these settings.
176
+ The sanitization process takes a hash configuration of settings. See the [Selma](https://www.github.com/gjtorikian/selma) documentation for more information on how to configure these settings. Note that users must correctly configure the sanitization configuration if they expect to use it correctly in conjunction with handlers which manipulate HTML.
177
177
 
178
178
  A default sanitization config is provided by this library (`HTMLPipeline::SanitizationFilter::DEFAULT_CONFIG`). A sample custom sanitization allowlist might look like this:
179
179
 
@@ -224,7 +224,7 @@ For more examples of customizing the sanitization process to include the tags yo
224
224
 
225
225
  `NodeFilters`s can operate either on HTML elements or text nodes using CSS selectors. Each `NodeFilter` must define a method named `selector` which provides an instance of `Selma::Selector`. If elements are being manipulated, `handle_element` must be defined, taking one argument, `element`; if text nodes are being manipulated, `handle_text_chunk` must be defined, taking one argument, `text_chunk`. `@config`, and `@result` are available to use, and any changes made to these ivars are passed on to the next filter.
226
226
 
227
- `NodeFilter` also has an optional method, `after_initialize`, which is run after the filter initializes. This can be useful in setting up a custom state for `result` to take advantage of.
227
+ `NodeFilter` also has an optional method, `after_initialize`, which is run after the filter initializes. This can be useful in setting up a fresh custom state for `result` to start from each time the pipeline is called.
228
228
 
229
229
  Here's an example `NodeFilter` that adds a base url to images that are root relative:
230
230
 
@@ -25,7 +25,7 @@ Gem::Specification.new do |gem|
25
25
  "rubygems_mfa_required" => "true",
26
26
  }
27
27
 
28
- gem.add_dependency("selma", "~> 0.1")
28
+ gem.add_dependency("selma", "~> 0.4")
29
29
  gem.add_dependency("zeitwerk", "~> 2.5")
30
30
 
31
31
  gem.post_install_message = <<~MSG
@@ -12,7 +12,7 @@ class HTMLPipeline
12
12
  # :markdown[:extensions] => Commonmarker extensions options
13
13
  class MarkdownFilter < ConvertFilter
14
14
  def initialize(context: {}, result: {})
15
- super(context: context, result: result)
15
+ super
16
16
  end
17
17
 
18
18
  # Convert Commonmark to HTML using the best available implementation.
@@ -5,7 +5,7 @@ class HTMLPipeline
5
5
  attr_reader :text, :html
6
6
 
7
7
  def initialize(context: {}, result: {})
8
- super(context: context, result: result)
8
+ super
9
9
  end
10
10
 
11
11
  class << self
@@ -15,7 +15,7 @@ class HTMLPipeline
15
15
  # This filter does not write any additional information to the context hash.
16
16
  class SyntaxHighlightFilter < NodeFilter
17
17
  def initialize(context: {}, result: {})
18
- super(context: context, result: result)
18
+ super
19
19
  # TODO: test the optionality of this
20
20
  @formatter = context[:formatter] || Rouge::Formatters::HTML.new
21
21
  end
@@ -5,7 +5,7 @@ class HTMLPipeline
5
5
  attr_reader :text
6
6
 
7
7
  def initialize(context: {}, result: {})
8
- super(context: context, result: result)
8
+ super
9
9
  end
10
10
 
11
11
  class << self
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class HTMLPipeline
4
- VERSION = "3.2.0"
4
+ VERSION = "3.2.1"
5
5
  end
data/lib/html_pipeline.rb CHANGED
@@ -175,11 +175,20 @@ class HTMLPipeline
175
175
  end
176
176
  end
177
177
 
178
- unless @node_filters.empty?
178
+ rewriter_options = {
179
+ memory: {
180
+ max_allowed_memory_usage: 5242880, # arbitrary limit of 5MB
181
+ },
182
+ }
183
+
184
+ if @node_filters.empty?
185
+ instrument("sanitization.html_pipeline", payload) do
186
+ result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
187
+ end unless @convert_filter.nil? # no html, so no sanitization
188
+ else
179
189
  instrument("call_node_filters.html_pipeline", payload) do
180
190
  @node_filters.each { |filter| filter.context = (filter.context || {}).merge(context) }
181
- result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
182
- html = result[:output]
191
+ result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters, options: rewriter_options).rewrite(html)
183
192
  payload = default_payload({
184
193
  node_filters: @node_filters.map { |f| f.class.name },
185
194
  context: context,
@@ -188,10 +197,6 @@ class HTMLPipeline
188
197
  end
189
198
  end
190
199
 
191
- instrument("sanitization.html_pipeline", payload) do
192
- result[:output] = Selma::Rewriter.new(sanitizer: @sanitization_config, handlers: @node_filters).rewrite(html)
193
- end
194
-
195
200
  result = result.merge(@node_filters.collect(&:result).reduce({}, :merge))
196
201
  @node_filters.each(&:reset!)
197
202
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen J. Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-30 00:00:00.000000000 Z
11
+ date: 2024-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selma
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.1'
19
+ version: '0.4'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.1'
26
+ version: '0.4'
27
27
  force_ruby_platform: false
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: zeitwerk