summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2018-07-24 14:08:24 -0700
committerStan Hu <stanhu@gmail.com>2018-07-24 14:08:24 -0700
commit1771b19464be8dd1f9ff1c20397cbb32efe9a892 (patch)
tree6b096ef3fea826717cccfba8db1ac0aacc9f4ece
parent236ed1f2f36df1a1a2245dbd2543d17071935313 (diff)
parentd1148002416d1b5a21ebf7fdf2a71b201743033a (diff)
downloadgitlab-ce-1771b19464be8dd1f9ff1c20397cbb32efe9a892.tar.gz
Merge remote-tracking branch 'origin/master' into dev-master
-rw-r--r--changelogs/unreleased/sh-revert-markdown-changes.yml5
-rw-r--r--lib/banzai/filter/sanitization_filter.rb2
-rw-r--r--spec/lib/banzai/filter/sanitization_filter_spec.rb12
3 files changed, 18 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-revert-markdown-changes.yml b/changelogs/unreleased/sh-revert-markdown-changes.yml
new file mode 100644
index 00000000000..72540f710a1
--- /dev/null
+++ b/changelogs/unreleased/sh-revert-markdown-changes.yml
@@ -0,0 +1,5 @@
+---
+title: Fix slow Markdown rendering
+merge_request: 20820
+author:
+type: performance
diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb
index 80b9d3d045f..8ba09290e6d 100644
--- a/lib/banzai/filter/sanitization_filter.rb
+++ b/lib/banzai/filter/sanitization_filter.rb
@@ -13,7 +13,7 @@ module Banzai
def whitelist
strong_memoize(:whitelist) do
- customize_whitelist(super.dup)
+ customize_whitelist(super.deep_dup)
end
end
diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb
index d930c608b18..0b3c2390304 100644
--- a/spec/lib/banzai/filter/sanitization_filter_spec.rb
+++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb
@@ -54,6 +54,18 @@ describe Banzai::Filter::SanitizationFilter do
expect(instance.whitelist[:transformers].size).to eq control_count
end
+ it 'customizes the whitelist only once for different instances' do
+ instance1 = described_class.new('Foo1')
+ instance2 = described_class.new('Foo2')
+ control_count = instance1.whitelist[:transformers].size
+
+ instance1.whitelist
+ instance2.whitelist
+
+ expect(instance1.whitelist[:transformers].size).to eq control_count
+ expect(instance2.whitelist[:transformers].size).to eq control_count
+ end
+
it 'sanitizes `class` attribute from all elements' do
act = %q{<pre class="code highlight white c"><code>&lt;span class="k"&gt;def&lt;/span&gt;</code></pre>}
exp = %q{<pre><code>&lt;span class="k"&gt;def&lt;/span&gt;</code></pre>}