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 +4 -4
- data/.github/workflows/publish.yml +7 -2
- data/CHANGELOG.md +13 -0
- data/Gemfile +1 -1
- data/README.md +3 -3
- data/html-pipeline.gemspec +1 -1
- data/lib/html_pipeline/convert_filter/markdown_filter.rb +1 -1
- data/lib/html_pipeline/convert_filter.rb +1 -1
- data/lib/html_pipeline/node_filter/syntax_highlight_filter.rb +1 -1
- data/lib/html_pipeline/text_filter.rb +1 -1
- data/lib/html_pipeline/version.rb +1 -1
- data/lib/html_pipeline.rb +12 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d505d0765630595363061d97d8f189a2712fc56b89371542a225d35421af386
|
4
|
+
data.tar.gz: 9d10f5ad3c9d39fe65d6e3b22cd59070997e5774353806affde0a957a52f5812
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
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
|
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
|
|
data/html-pipeline.gemspec
CHANGED
@@ -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
|
15
|
+
super
|
16
16
|
end
|
17
17
|
|
18
18
|
# Convert Commonmark to HTML using the best available implementation.
|
@@ -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
|
18
|
+
super
|
19
19
|
# TODO: test the optionality of this
|
20
20
|
@formatter = context[:formatter] || Rouge::Formatters::HTML.new
|
21
21
|
end
|
data/lib/html_pipeline.rb
CHANGED
@@ -175,11 +175,20 @@ class HTMLPipeline
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
|
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.
|
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-
|
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.
|
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.
|
26
|
+
version: '0.4'
|
27
27
|
force_ruby_platform: false
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: zeitwerk
|