|
1480 | 1480 | MARKDOWN
|
1481 | 1481 | end
|
1482 | 1482 |
|
1483 |
| - it "does not sanitize embed code" do |
1484 |
| - should eq <<-HTML.strip_heredoc |
1485 |
| - <iframe width="100" height="100" src="https://www.youtube.com/embed/example"></iframe> |
1486 |
| - HTML |
| 1483 | + if allowed |
| 1484 | + it "does not sanitize embed code" do |
| 1485 | + should eq <<-HTML.strip_heredoc |
| 1486 | + <iframe width="100" height="100" src="https://www.youtube.com/embed/example"></iframe> |
| 1487 | + HTML |
| 1488 | + end |
| 1489 | + else |
| 1490 | + it "forces width attribute on iframe" do |
| 1491 | + should eq <<-HTML.strip_heredoc |
| 1492 | + <iframe width="100%" height="100" src="https://www.youtube.com/embed/example"></iframe> |
| 1493 | + HTML |
| 1494 | + end |
1487 | 1495 | end
|
1488 | 1496 |
|
1489 | 1497 | context "when url is privacy enhanced mode" do
|
|
1493 | 1501 | MARKDOWN
|
1494 | 1502 | end
|
1495 | 1503 |
|
1496 |
| - it "does not sanitize embed code" do |
1497 |
| - should eq <<-HTML.strip_heredoc |
1498 |
| - <iframe width="100" height="100" src="https://www.youtube-nocookie.com/embed/example"></iframe> |
1499 |
| - HTML |
| 1504 | + if allowed |
| 1505 | + it "does not sanitize embed code" do |
| 1506 | + should eq <<-HTML.strip_heredoc |
| 1507 | + <iframe width="100" height="100" src="https://www.youtube-nocookie.com/embed/example"></iframe> |
| 1508 | + HTML |
| 1509 | + end |
| 1510 | + else |
| 1511 | + it "forces width attribute on iframe" do |
| 1512 | + should eq <<-HTML.strip_heredoc |
| 1513 | + <iframe width="100%" height="100" src="https://www.youtube-nocookie.com/embed/example"></iframe> |
| 1514 | + HTML |
| 1515 | + end |
1500 | 1516 | end
|
1501 | 1517 | end
|
1502 | 1518 | end
|
|
1508 | 1524 | MARKDOWN
|
1509 | 1525 | end
|
1510 | 1526 |
|
1511 |
| - it "does not sanitize embed code" do |
1512 |
| - should eq <<-HTML.strip_heredoc |
1513 |
| - <iframe width="100" height="100" src="https://www.slideshare.net/embed/example"></iframe> |
1514 |
| - HTML |
| 1527 | + if allowed |
| 1528 | + it "does not sanitize embed code" do |
| 1529 | + should eq <<-HTML.strip_heredoc |
| 1530 | + <iframe width="100" height="100" src="https://www.slideshare.net/embed/example"></iframe> |
| 1531 | + HTML |
| 1532 | + end |
| 1533 | + else |
| 1534 | + it "forces width attribute on iframe" do |
| 1535 | + should eq <<-HTML.strip_heredoc |
| 1536 | + <iframe width="100%" height="100" src="https://www.slideshare.net/embed/example"></iframe> |
| 1537 | + HTML |
| 1538 | + end |
1515 | 1539 | end
|
1516 | 1540 | end
|
1517 | 1541 |
|
|
1522 | 1546 | MARKDOWN
|
1523 | 1547 | end
|
1524 | 1548 |
|
1525 |
| - it "does not sanitize embed code" do |
1526 |
| - should eq <<-HTML.strip_heredoc |
1527 |
| - <iframe src="https://docs.google.com/presentation/d/example/embed" frameborder="0" width="482" height="300" allowfullscreen="true"></iframe> |
1528 |
| - HTML |
| 1549 | + if allowed |
| 1550 | + it "does not sanitize embed code" do |
| 1551 | + should eq <<-HTML.strip_heredoc |
| 1552 | + <iframe src="https://docs.google.com/presentation/d/example/embed" frameborder="0" width="482" height="300" allowfullscreen="true"></iframe> |
| 1553 | + HTML |
| 1554 | + end |
| 1555 | + else |
| 1556 | + it "forces width attribute on iframe" do |
| 1557 | + should eq <<-HTML.strip_heredoc |
| 1558 | + <iframe src="https://docs.google.com/presentation/d/example/embed" frameborder="0" width="100%" height="300" allowfullscreen="true"></iframe> |
| 1559 | + HTML |
| 1560 | + end |
1529 | 1561 | end
|
1530 | 1562 | end
|
1531 | 1563 |
|
|
1566 | 1598 | HTML
|
1567 | 1599 | end
|
1568 | 1600 | end
|
| 1601 | + |
| 1602 | + context "with embed script code with xss" do |
| 1603 | + let(:markdown) do |
| 1604 | + <<-MARKDOWN.strip_heredoc |
| 1605 | + <script async class="speakerdeck-embed" data-id="example" data-ratio="1.33333333333333" src="javascript://speakerdeck.com/assets/embed.js"></script> |
| 1606 | + MARKDOWN |
| 1607 | + |
| 1608 | + it "forces width attribute on iframe" do |
| 1609 | + should eq <<-HTML.strip_heredoc |
| 1610 | + \n |
| 1611 | + HTML |
| 1612 | + end |
| 1613 | + end |
| 1614 | + end |
| 1615 | + |
| 1616 | + context "with embed iframe code with xss" do |
| 1617 | + let(:markdown) do |
| 1618 | + <<-MARKDOWN.strip_heredoc |
| 1619 | + <iframe src="javascript://docs.google.com/presentation/d/example/embed" frameborder="0" width="482" height="300" allowfullscreen="true" mozallowfullscreen="true" webkitallowfullscreen="true"></iframe> |
| 1620 | + MARKDOWN |
| 1621 | + |
| 1622 | + it "forces width attribute on iframe" do |
| 1623 | + should eq <<-HTML.strip_heredoc |
| 1624 | + \n |
| 1625 | + HTML |
| 1626 | + end |
| 1627 | + end |
| 1628 | + end |
1569 | 1629 | end
|
1570 | 1630 |
|
1571 | 1631 | context "without script and strict context" do
|
|
0 commit comments