Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

Allow width, height, and valign attributes on img tags #50

Merged
merged 1 commit into from
Oct 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/sanitize.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sanitizer.config = {
h5: ['id'],
h6: ['id'],
a: ['href', 'id', 'name', 'target'],
img: ['id', 'src'],
img: ['id', 'src', 'width', 'height', 'valign'],
meta: ['name', 'content'],
iframe: ['src', 'frameborder', 'allowfullscreen'],
div: [],
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/dirty.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<script charset="utf-8" src="http://malware.com" type="text/javascript">alert("haxorz")</script>

<img src="local.png"></img>
<img src="local.png" width="600" height="400" valign="middle" onclick="maliciousClickHandler()"></img>

<a class="xxx" href="http://yyy.com">zzz</a>

Expand Down
4 changes: 4 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ describe('sanitize', function () {

it('allows img tags', function () {
assert($('img').length)
assert.equal($('img').attr('width'), "600")
assert.equal($('img').attr('height'), "400")
assert.equal($('img').attr('valign'), "middle")
assert.equal($('img').attr('onclick'), undefined)
})

it('allows h1/h2/h3/h4/h5/h6 tags to preserve their dom id', function () {
Expand Down