0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-12-21 16:01:53 +00:00

feat: Allow more image widths by default (#430)

This commit is contained in:
Tim Otten 2024-12-11 11:15:46 -08:00 committed by GitHub
parent 63e631ebd3
commit 00a0748427
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 10 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
CSS.MaxImgLength
TYPE: string/null
DEFAULT: '1200px'
DEFAULT: null
VERSION: 3.1.1
--DESCRIPTION--
<p>

View File

@ -1,6 +1,6 @@
HTML.MaxImgLength
TYPE: int/null
DEFAULT: 1200
DEFAULT: null
VERSION: 3.1.1
--DESCRIPTION--
<p>

View File

@ -11,6 +11,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
public function testLengthTooLarge()
{
$this->config->set('HTML.MaxImgLength', 1200);
$this->assertResult(
'<img height="40000" width="40000" src="" alt="" />',
'<img height="1200" width="1200" src="" alt="" />'
@ -19,6 +20,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
public function testLengthPercentage()
{
$this->config->set('HTML.MaxImgLength', 1200);
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />',
'<img src="" alt="" />'

View File

@ -6,6 +6,7 @@ class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarne
public function setUp()
{
parent::setUp();
$this->config->set('HTML.MaxImgLength', 1200);
$def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeEmbed');
}

View File

@ -8,6 +8,7 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
parent::setUp();
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest');
$this->config->set('HTML.SafeObject', true);
$this->config->set('HTML.MaxImgLength', 1200);
}
public function testMinimal()

View File

@ -211,6 +211,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
public function testRemoveLargeCSSWidthAndHeightOnImg()
{
$this->config->set('CSS.MaxImgLength', '1200px');
$this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
@ -244,6 +245,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
public function testRemoveRelativeCSSWidthAndHeightOnImg()
{
$this->config->set('CSS.MaxImgLength', '1200px');
$this->assertResult(
'<img src="" alt="" style="width:10em;height:10em;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
@ -252,6 +254,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
public function testRemovePercentCSSWidthAndHeightOnImg()
{
$this->config->set('CSS.MaxImgLength', '1200px');
$this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'