2008-05-23 02:09:43 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
|
|
|
|
{
|
2008-12-06 07:28:20 +00:00
|
|
|
|
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testNormal()
|
|
|
|
{
|
2008-05-23 02:09:43 +00:00
|
|
|
$this->assertResult('<img height="40" width="40" src="" alt="" />');
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLengthTooLarge()
|
|
|
|
{
|
2008-05-23 02:09:43 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<img height="40000" width="40000" src="" alt="" />',
|
|
|
|
'<img height="1200" width="1200" src="" alt="" />'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLengthPercentage()
|
|
|
|
{
|
2008-05-23 02:09:43 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<img height="100%" width="100%" src="" alt="" />',
|
|
|
|
'<img src="" alt="" />'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLengthCustomMax()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.MaxImgLength', 20);
|
2008-05-23 02:09:43 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<img height="30" width="30" src="" alt="" />',
|
|
|
|
'<img height="20" width="20" src="" alt="" />'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLengthCrashFixDisabled()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.MaxImgLength', null);
|
2008-05-23 02:09:43 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<img height="100%" width="100%" src="" alt="" />'
|
|
|
|
);
|
|
|
|
$this->assertResult(
|
|
|
|
'<img height="40000" width="40000" src="" alt="" />'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2013-07-16 11:56:14 +00:00
|
|
|
public function testLengthTrusted()
|
|
|
|
{
|
2009-02-20 00:17:49 +00:00
|
|
|
$this->config->set('HTML.Trusted', true);
|
2008-05-23 02:09:43 +00:00
|
|
|
$this->assertResult(
|
|
|
|
'<img height="100%" width="100%" src="" alt="" />'
|
|
|
|
);
|
|
|
|
$this->assertResult(
|
|
|
|
'<img height="40000" width="40000" src="" alt="" />'
|
|
|
|
);
|
|
|
|
}
|
2008-12-06 07:28:20 +00:00
|
|
|
|
2008-05-23 02:09:43 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 09:24:59 +00:00
|
|
|
// vim: et sw=4 sts=4
|