From 8e1e42367373c39aaaf88570af368282983b0d83 Mon Sep 17 00:00:00 2001 From: Brett Walker <bwalker@gitlab.com> Date: Tue, 23 May 2023 16:34:54 -0500 Subject: [PATCH] Bump commonmarker gem to 0.23.9 Allow new data-footnote-backref-idx attribute Changelog: changed --- Gemfile | 2 +- Gemfile.checksum | 2 +- Gemfile.lock | 4 +-- .../output_example_snapshots/html.yml | 28 +++++++++---------- lib/banzai/filter/sanitization_filter.rb | 2 +- .../lib/banzai/filter/footnote_filter_spec.rb | 12 ++++---- .../banzai/filter/sanitization_filter_spec.rb | 12 ++++++++ .../lib/banzai/pipeline/full_pipeline_spec.rb | 6 ++-- 8 files changed, 40 insertions(+), 28 deletions(-) diff --git a/Gemfile b/Gemfile index b50baa992a1b..770f5f22d23f 100644 --- a/Gemfile +++ b/Gemfile @@ -182,7 +182,7 @@ gem 'typhoeus', '~> 1.4.0' # Used with Elasticsearch to support http keep-alive gem 'html-pipeline', '~> 2.14.3' gem 'deckar01-task_list', '2.3.2' gem 'gitlab-markup', '~> 1.9.0', require: 'github/markup' -gem 'commonmarker', '~> 0.23.6' +gem 'commonmarker', '~> 0.23.9' gem 'kramdown', '~> 2.3.1' gem 'RedCloth', '~> 4.3.2' gem 'rdoc', '~> 6.3.2' diff --git a/Gemfile.checksum b/Gemfile.checksum index f6f50484232b..b5b3de81ca46 100644 --- a/Gemfile.checksum +++ b/Gemfile.checksum @@ -84,7 +84,7 @@ {"name":"coderay","version":"1.1.3","platform":"ruby","checksum":"dc530018a4684512f8f38143cd2a096c9f02a1fc2459edcfe534787a7fc77d4b"}, {"name":"coercible","version":"1.0.0","platform":"ruby","checksum":"5081ad24352cc8435ce5472bc2faa30260c7ea7f2102cc6a9f167c4d9bffaadc"}, {"name":"colored2","version":"3.1.2","platform":"ruby","checksum":"b13c2bd7eeae2cf7356a62501d398e72fde78780bd26aec6a979578293c28b4a"}, -{"name":"commonmarker","version":"0.23.6","platform":"ruby","checksum":"c8aeaaaff4ba497bf180f762db63a0069794fafb6eff221224c9c8199d337b38"}, +{"name":"commonmarker","version":"0.23.9","platform":"ruby","checksum":"2e739c85a6961531cb6f5ba5169f2c7f64471b7e700c64b048ec22a5b230811c"}, {"name":"concurrent-ruby","version":"1.2.2","platform":"ruby","checksum":"3879119b8b75e3b62616acc256c64a134d0b0a7a9a3fcba5a233025bcde22c4f"}, {"name":"connection_pool","version":"2.3.0","platform":"ruby","checksum":"677985be912f33c90f98f229aaa0c0ddb2ef8776f21929a36eeeb25251c944da"}, {"name":"cork","version":"0.3.0","platform":"ruby","checksum":"a0a0ac50e262f8514d1abe0a14e95e71c98b24e3378690e5d044daf0013ad4bc"}, diff --git a/Gemfile.lock b/Gemfile.lock index fe45768cdf94..1e10fda5c9fa 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -307,7 +307,7 @@ GEM coercible (1.0.0) descendants_tracker (~> 0.0.1) colored2 (3.1.2) - commonmarker (0.23.6) + commonmarker (0.23.9) concurrent-ruby (1.2.2) connection_pool (2.3.0) cork (0.3.0) @@ -1690,7 +1690,7 @@ DEPENDENCIES charlock_holmes (~> 0.7.7) circuitbox (= 2.0.0) cloud_profiler_agent (~> 0.0.0)! - commonmarker (~> 0.23.6) + commonmarker (~> 0.23.9) concurrent-ruby (~> 1.1) connection_pool (~> 2.0) countries (~> 4.0.0) diff --git a/glfm_specification/output_example_snapshots/html.yml b/glfm_specification/output_example_snapshots/html.yml index d1c41e84a26e..d29adfcde228 100644 --- a/glfm_specification/output_example_snapshots/html.yml +++ b/glfm_specification/output_example_snapshots/html.yml @@ -5494,7 +5494,7 @@ canonical: | <p><strong>foo, <strong>bar</strong>, baz</strong></p> static: |- - <p data-sourcepos="1:1-1:21" dir="auto"><strong>foo, <strong>bar</strong>, baz</strong></p> + <p data-sourcepos="1:1-1:21" dir="auto"><strong>foo, bar, baz</strong></p> wysiwyg: |- <p><strong>foo, bar</strong>, baz</p> 06_05_00__inlines__emphasis_and_strong_emphasis__040: @@ -5696,7 +5696,7 @@ canonical: | <p>foo<strong><strong><strong>bar</strong></strong></strong>***baz</p> static: |- - <p data-sourcepos="1:1-1:24" dir="auto">foo<strong><strong><strong>bar</strong></strong></strong>***baz</p> + <p data-sourcepos="1:1-1:24" dir="auto">foo<strong>bar</strong>***baz</p> wysiwyg: |- <p>foo<strong>bar</strong>***baz</p> 06_05_00__inlines__emphasis_and_strong_emphasis__068: @@ -5755,21 +5755,21 @@ canonical: | <p><strong>foo <strong>bar</strong> baz</strong></p> static: |- - <p data-sourcepos="1:1-1:19" dir="auto"><strong>foo <strong>bar</strong> baz</strong></p> + <p data-sourcepos="1:1-1:19" dir="auto"><strong>foo bar baz</strong></p> wysiwyg: |- <p><strong>foo bar</strong> baz</p> 06_05_00__inlines__emphasis_and_strong_emphasis__076: canonical: | <p><strong><strong>foo</strong> bar</strong></p> static: |- - <p data-sourcepos="1:1-1:15" dir="auto"><strong><strong>foo</strong> bar</strong></p> + <p data-sourcepos="1:1-1:15" dir="auto"><strong>foo bar</strong></p> wysiwyg: |- <p><strong>foo</strong> bar</p> 06_05_00__inlines__emphasis_and_strong_emphasis__077: canonical: | <p><strong>foo <strong>bar</strong></strong></p> static: |- - <p data-sourcepos="1:1-1:15" dir="auto"><strong>foo <strong>bar</strong></strong></p> + <p data-sourcepos="1:1-1:15" dir="auto"><strong>foo bar</strong></p> wysiwyg: |- <p><strong>foo bar</strong></p> 06_05_00__inlines__emphasis_and_strong_emphasis__078: @@ -6031,21 +6031,21 @@ canonical: | <p><strong><strong>foo</strong></strong></p> static: |- - <p data-sourcepos="1:1-1:11" dir="auto"><strong><strong>foo</strong></strong></p> + <p data-sourcepos="1:1-1:11" dir="auto"><strong>foo</strong></p> wysiwyg: |- <p><strong>foo</strong></p> 06_05_00__inlines__emphasis_and_strong_emphasis__115: canonical: | <p><strong><strong>foo</strong></strong></p> static: |- - <p data-sourcepos="1:1-1:11" dir="auto"><strong><strong>foo</strong></strong></p> + <p data-sourcepos="1:1-1:11" dir="auto"><strong>foo</strong></p> wysiwyg: |- <p><strong>foo</strong></p> 06_05_00__inlines__emphasis_and_strong_emphasis__116: canonical: | <p><strong><strong><strong>foo</strong></strong></strong></p> static: |- - <p data-sourcepos="1:1-1:15" dir="auto"><strong><strong><strong>foo</strong></strong></strong></p> + <p data-sourcepos="1:1-1:15" dir="auto"><strong>foo</strong></p> wysiwyg: |- <p><strong>foo</strong></p> 06_05_00__inlines__emphasis_and_strong_emphasis__117: @@ -6059,7 +6059,7 @@ canonical: | <p><em><strong><strong>foo</strong></strong></em></p> static: |- - <p data-sourcepos="1:1-1:13" dir="auto"><em><strong><strong>foo</strong></strong></em></p> + <p data-sourcepos="1:1-1:13" dir="auto"><em><strong>foo</strong></em></p> wysiwyg: |- <p><strong><em>foo</em></strong></p> 06_05_00__inlines__emphasis_and_strong_emphasis__119: @@ -7392,7 +7392,7 @@ canonical: | <p>foo <!-- not a comment -- two hyphens --></p> static: |- - <p data-sourcepos="1:1-1:41" dir="auto">foo <!-- not a comment -- two hyphens --></p> + <p data-sourcepos="1:1-1:41" dir="auto">foo <!-- not a comment -- two hyphens --></p> wysiwyg: |- <p>foo <!-- not a comment -- two hyphens --></p> 06_11_00__inlines__raw_html__015: @@ -7400,7 +7400,7 @@ <p>foo <!--> foo --></p> <p>foo <!-- foo---></p> static: |- - <p data-sourcepos="1:1-1:17" dir="auto">foo <!--> foo --></p> + <p data-sourcepos="1:1-1:17" dir="auto">foo <!----> foo --></p> <p data-sourcepos="3:1-3:16" dir="auto">foo <!-- foo---></p> wysiwyg: |- <p>foo <!--> foo --></p> @@ -8238,10 +8238,10 @@ <section data-footnotes class="footnotes"> <ol> <li id="fn-1-42"> - <p data-sourcepos="5:7-5:41">This is the text inside a footnote. <a href="#fnref-1-42" data-footnote-backref aria-label="Back to content" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> + <p data-sourcepos="5:7-5:41">This is the text inside a footnote. <a href="#fnref-1-42" data-footnote-backref data-footnote-backref-idx="1" aria-label="Back to reference 1" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> </li> <li id="fn-footnote-42"> - <p data-sourcepos="7:14-7:38">This is another footnote. <a href="#fnref-footnote-42" data-footnote-backref aria-label="Back to content" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> + <p data-sourcepos="7:14-7:38">This is another footnote. <a href="#fnref-footnote-42" data-footnote-backref data-footnote-backref-idx="2" aria-label="Back to reference 2" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> </li> </ol> </section> @@ -8643,7 +8643,7 @@ <section data-footnotes class="footnotes"> <ol> <li id="fn-fortytwo-42"> - <p data-sourcepos="3:14-3:26">footnote text <a href="#fnref-fortytwo-42" data-footnote-backref aria-label="Back to content" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> + <p data-sourcepos="3:14-3:26">footnote text <a href="#fnref-fortytwo-42" data-footnote-backref data-footnote-backref-idx="1" aria-label="Back to reference 1" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> </li> </ol> </section> diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb index b119c2ffccf5..c2cad237d6fe 100644 --- a/lib/banzai/filter/sanitization_filter.rb +++ b/lib/banzai/filter/sanitization_filter.rb @@ -34,7 +34,7 @@ def customize_allowlist(allowlist) # Allow section elements with data-footnotes attribute allowlist[:elements].push('section') allowlist[:attributes]['section'] = %w(data-footnotes) - allowlist[:attributes]['a'].push('data-footnote-ref', 'data-footnote-backref') + allowlist[:attributes]['a'].push('data-footnote-ref', 'data-footnote-backref', 'data-footnote-backref-idx') allowlist end diff --git a/spec/lib/banzai/filter/footnote_filter_spec.rb b/spec/lib/banzai/filter/footnote_filter_spec.rb index 4b765191449f..5dd5074801f2 100644 --- a/spec/lib/banzai/filter/footnote_filter_spec.rb +++ b/spec/lib/banzai/filter/footnote_filter_spec.rb @@ -18,12 +18,12 @@ <section data-footnotes> <ol> <li id="fn-1"> - <p>one <a href="#fnref-1" aria-label="Back to content" data-footnote-backref>↩</a></p> + <p>one <a href="#fnref-1" data-footnote-backref data-footnote-backref-idx="1" aria-label="Back to reference 1">↩</a></p> </li> <li id="fn-second"> - <p>two <a href="#fnref-second" aria-label="Back to content" data-footnote-backref>↩</a></p> + <p>two <a href="#fnref-second" data-footnote-backref data-footnote-backref-idx="2" aria-label="Back to reference 2">↩</a></p> </li>\n<li id="fn-_%F0%9F%98%84_"> - <p>three <a href="#fnref-_%F0%9F%98%84_" aria-label="Back to content" data-footnote-backref>↩</a></p> + <p>three <a href="#fnref-_%F0%9F%98%84_" data-footnote-backref data-footnote-backref-idx="3" aria-label="Back to reference 3">↩</a></p> </li> </ol> EOF @@ -35,13 +35,13 @@ <section data-footnotes class=\"footnotes\"> <ol> <li id="fn-1-#{identifier}"> - <p>one <a href="#fnref-1-#{identifier}" aria-label="Back to content" data-footnote-backref class="footnote-backref">↩</a></p> + <p>one <a href="#fnref-1-#{identifier}" data-footnote-backref data-footnote-backref-idx="1" aria-label="Back to reference 1" class="footnote-backref">↩</a></p> </li> <li id="fn-second-#{identifier}"> - <p>two <a href="#fnref-second-#{identifier}" aria-label="Back to content" data-footnote-backref class="footnote-backref">↩</a></p> + <p>two <a href="#fnref-second-#{identifier}" data-footnote-backref data-footnote-backref-idx="2" aria-label="Back to reference 2" class="footnote-backref">↩</a></p> </li> <li id="fn-_%F0%9F%98%84_-#{identifier}"> - <p>three <a href="#fnref-_%F0%9F%98%84_-#{identifier}" aria-label="Back to content" data-footnote-backref class="footnote-backref">↩</a></p> + <p>three <a href="#fnref-_%F0%9F%98%84_-#{identifier}" data-footnote-backref data-footnote-backref-idx="3" aria-label="Back to reference 3" class="footnote-backref">↩</a></p> </li> </ol> </section> diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb index 51832e607543..bad09732e003 100644 --- a/spec/lib/banzai/filter/sanitization_filter_spec.rb +++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb @@ -144,6 +144,18 @@ end describe 'footnotes' do + it 'allows the footnote attributes' do + exp = <<~HTML + <section data-footnotes> + <a href="#fn-first" id="fnref-first" data-footnote-ref data-footnote-backref data-footnote-backref-idx>foo/bar.md</a> + </section> + HTML + + act = filter(exp) + + expect(act.to_html).to eq exp + end + it 'allows correct footnote id property on links' do exp = %q(<a href="#fn-first" id="fnref-first">foo/bar.md</a>) act = filter(exp) diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb index ca05a353d47a..6654eec72414 100644 --- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb @@ -49,13 +49,13 @@ <section data-footnotes class="footnotes"> <ol> <li id="fn-1-#{identifier}"> - <p>one <a href="#fnref-1-#{identifier}" data-footnote-backref aria-label="Back to content" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> + <p>one <a href="#fnref-1-#{identifier}" data-footnote-backref data-footnote-backref-idx="1" aria-label="Back to reference 1" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> </li> <li id="fn-%F0%9F%98%84second-#{identifier}"> - <p>two <a href="#fnref-%F0%9F%98%84second-#{identifier}" data-footnote-backref aria-label="Back to content" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> + <p>two <a href="#fnref-%F0%9F%98%84second-#{identifier}" data-footnote-backref data-footnote-backref-idx="2" aria-label="Back to reference 2" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> </li> <li id="fn-_twenty-#{identifier}"> - <p>twenty <a href="#fnref-_twenty-#{identifier}" data-footnote-backref aria-label="Back to content" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> + <p>twenty <a href="#fnref-_twenty-#{identifier}" data-footnote-backref data-footnote-backref-idx="3" aria-label="Back to reference 3" class="footnote-backref"><gl-emoji title="leftwards arrow with hook" data-name="leftwards_arrow_with_hook" data-unicode-version="1.1">↩</gl-emoji></a></p> </li> </ol> </section> -- GitLab