qiita-markdown 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of qiita-markdown might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +2 -1
- data/CHANGELOG.md +4 -0
- data/lib/qiita/markdown.rb +2 -1
- data/lib/qiita/markdown/embed/code_pen.rb +10 -0
- data/lib/qiita/markdown/embed/tweet.rb +10 -0
- data/lib/qiita/markdown/filters/final_sanitizer.rb +2 -2
- data/lib/qiita/markdown/filters/user_input_sanitizer.rb +1 -1
- data/lib/qiita/markdown/transformers/filter_attributes.rb +1 -1
- data/lib/qiita/markdown/transformers/filter_script.rb +2 -1
- data/lib/qiita/markdown/version.rb +1 -1
- data/spec/qiita/markdown/processor_spec.rb +30 -5
- metadata +4 -3
- data/lib/qiita/markdown/code_pen.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16c43409c5b2bdceefb568344cf9280e7d1e50b2
|
4
|
+
data.tar.gz: f4225f554071f1e8c8c339248f08b3ef5253be46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a9edc2d4826bfefd294ad32cf556fbb6985ac94d4e91a435a9513f6aec51c1a58bc435eebd45350e275ad1e5314c188c0e56bd3d56bc6130d9fcbe18f72ba6e
|
7
|
+
data.tar.gz: 2da9ab1ee70db812a391875522e53606991f177d1f66b7da80192b9db1bbda9cc83d101cb6b01fd292c6dc405b35ccac4cc01a694d7f872b9e7ae5b01bc19155
|
data/.rubocop_todo.yml
CHANGED
@@ -52,12 +52,13 @@ Style/FileName:
|
|
52
52
|
# Cop supports --auto-correct.
|
53
53
|
Style/MutableConstant:
|
54
54
|
Exclude:
|
55
|
+
- 'lib/qiita/markdown/embed/code_pen.rb'
|
56
|
+
- 'lib/qiita/markdown/embed/tweet.rb'
|
55
57
|
- 'lib/qiita/markdown/filters/checkbox.rb'
|
56
58
|
- 'lib/qiita/markdown/filters/code_block.rb'
|
57
59
|
- 'lib/qiita/markdown/filters/sanitize.rb'
|
58
60
|
- 'lib/qiita/markdown/filters/simplify.rb'
|
59
61
|
- 'lib/qiita/markdown/filters/syntax_highlight.rb'
|
60
|
-
- 'lib/qiita/markdown/code_pen.rb'
|
61
62
|
- 'lib/qiita/markdown/processor.rb'
|
62
63
|
- 'lib/qiita/markdown/summary_processor.rb'
|
63
64
|
- 'lib/qiita/markdown/version.rb'
|
data/CHANGELOG.md
CHANGED
data/lib/qiita/markdown.rb
CHANGED
@@ -7,7 +7,8 @@ require "nokogiri"
|
|
7
7
|
require "pygments"
|
8
8
|
require "sanitize"
|
9
9
|
|
10
|
-
require "qiita/markdown/code_pen"
|
10
|
+
require "qiita/markdown/embed/code_pen"
|
11
|
+
require "qiita/markdown/embed/tweet"
|
11
12
|
require "qiita/markdown/transformers/filter_attributes"
|
12
13
|
require "qiita/markdown/transformers/filter_script"
|
13
14
|
require "qiita/markdown/transformers/strip_invalid_node"
|
@@ -41,7 +41,7 @@ module Qiita
|
|
41
41
|
"itemscope",
|
42
42
|
"itemtype",
|
43
43
|
],
|
44
|
-
"p" => CodePen::ATTRIBUTES,
|
44
|
+
"p" => Embed::CodePen::ATTRIBUTES,
|
45
45
|
"script" => [
|
46
46
|
"async",
|
47
47
|
"src",
|
@@ -191,7 +191,7 @@ module Qiita
|
|
191
191
|
SCRIPTABLE_RULE = RULE.dup.tap do |rule|
|
192
192
|
rule[:attributes] = RULE[:attributes].dup
|
193
193
|
rule[:attributes][:all] = rule[:attributes][:all] + [:data]
|
194
|
-
rule[:elements] = RULE[:elements] + ["iframe", "
|
194
|
+
rule[:elements] = RULE[:elements] + ["iframe", "video"]
|
195
195
|
rule[:transformers] = rule[:transformers] - [Transformers::FilterScript]
|
196
196
|
end
|
197
197
|
|
@@ -1312,7 +1312,7 @@ describe Qiita::Markdown::Processor do
|
|
1312
1312
|
end
|
1313
1313
|
end
|
1314
1314
|
|
1315
|
-
shared_examples_for "override
|
1315
|
+
shared_examples_for "override embed code attributes" do |allowed:|
|
1316
1316
|
context "with HTML embed code for CodePen" do
|
1317
1317
|
let(:markdown) do
|
1318
1318
|
<<-EOS.strip_heredoc
|
@@ -1337,6 +1337,31 @@ describe Qiita::Markdown::Processor do
|
|
1337
1337
|
end
|
1338
1338
|
end
|
1339
1339
|
end
|
1340
|
+
|
1341
|
+
context "with embed code for Tweet" do
|
1342
|
+
let(:markdown) do
|
1343
|
+
<<-EOS.strip_heredoc
|
1344
|
+
<blockquote class="twitter-tweet" data-cards="hidden" data-conversation="none">foo</blockquote>
|
1345
|
+
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
|
1346
|
+
EOS
|
1347
|
+
end
|
1348
|
+
|
1349
|
+
if allowed
|
1350
|
+
it "does not sanitize embed code" do
|
1351
|
+
should eq <<-EOS.strip_heredoc
|
1352
|
+
<blockquote class="twitter-tweet" data-cards="hidden" data-conversation="none">foo</blockquote>\n
|
1353
|
+
<script async src="https://platform.twitter.com/widgets.js"></script>
|
1354
|
+
EOS
|
1355
|
+
end
|
1356
|
+
else
|
1357
|
+
it "sanitizes attributes except `twitter-tweet` class" do
|
1358
|
+
should eq <<-EOS.strip_heredoc
|
1359
|
+
<blockquote class="twitter-tweet">foo</blockquote>\n
|
1360
|
+
<script async src="https://platform.twitter.com/widgets.js"></script>
|
1361
|
+
EOS
|
1362
|
+
end
|
1363
|
+
end
|
1364
|
+
end
|
1340
1365
|
end
|
1341
1366
|
|
1342
1367
|
context "without script and strict context" do
|
@@ -1352,7 +1377,7 @@ describe Qiita::Markdown::Processor do
|
|
1352
1377
|
include_examples "data-attributes", allowed: false
|
1353
1378
|
include_examples "class attribute", allowed: true
|
1354
1379
|
include_examples "background-color", allowed: true
|
1355
|
-
include_examples "override
|
1380
|
+
include_examples "override embed code attributes", allowed: false
|
1356
1381
|
end
|
1357
1382
|
|
1358
1383
|
context "with script context" do
|
@@ -1368,7 +1393,7 @@ describe Qiita::Markdown::Processor do
|
|
1368
1393
|
include_examples "data-attributes", allowed: true
|
1369
1394
|
include_examples "class attribute", allowed: true
|
1370
1395
|
include_examples "background-color", allowed: true
|
1371
|
-
include_examples "override
|
1396
|
+
include_examples "override embed code attributes", allowed: true
|
1372
1397
|
end
|
1373
1398
|
|
1374
1399
|
context "with strict context" do
|
@@ -1384,7 +1409,7 @@ describe Qiita::Markdown::Processor do
|
|
1384
1409
|
include_examples "data-attributes", allowed: false
|
1385
1410
|
include_examples "class attribute", allowed: false
|
1386
1411
|
include_examples "background-color", allowed: false
|
1387
|
-
include_examples "override
|
1412
|
+
include_examples "override embed code attributes", allowed: false
|
1388
1413
|
end
|
1389
1414
|
|
1390
1415
|
context "with script and strict context" do
|
@@ -1400,7 +1425,7 @@ describe Qiita::Markdown::Processor do
|
|
1400
1425
|
include_examples "data-attributes", allowed: false
|
1401
1426
|
include_examples "class attribute", allowed: false
|
1402
1427
|
include_examples "background-color", allowed: false
|
1403
|
-
include_examples "override
|
1428
|
+
include_examples "override embed code attributes", allowed: false
|
1404
1429
|
end
|
1405
1430
|
end
|
1406
1431
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita-markdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gemoji
|
@@ -256,7 +256,8 @@ files:
|
|
256
256
|
- lib/qiita-markdown.rb
|
257
257
|
- lib/qiita/markdown.rb
|
258
258
|
- lib/qiita/markdown/base_processor.rb
|
259
|
-
- lib/qiita/markdown/code_pen.rb
|
259
|
+
- lib/qiita/markdown/embed/code_pen.rb
|
260
|
+
- lib/qiita/markdown/embed/tweet.rb
|
260
261
|
- lib/qiita/markdown/filters/checkbox.rb
|
261
262
|
- lib/qiita/markdown/filters/code_block.rb
|
262
263
|
- lib/qiita/markdown/filters/emoji.rb
|