Skip to content

Commit 3619a6c

Browse files
committed
Only modify the behavior of Size::render for numbers that are going to be printed in scientific notation
1 parent 77908d1 commit 3619a6c

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

lib/Sabberworm/CSS/Value/Size.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public function __toString() {
116116
public function render(\Sabberworm\CSS\OutputFormat $oOutputFormat) {
117117
$l = localeconv();
118118
$sPoint = preg_quote($l['decimal_point'], '/');
119-
$sSize = $this->fSize != 0 ? preg_replace("/$sPoint?0+$/", "", sprintf("%f", $this->fSize)) : 0;
119+
$sSize = preg_match("/[\d\.]+e[+-]?\d+/i", (string)$this->fSize) ? preg_replace("/$sPoint?0+$/", "", sprintf("%f", $this->fSize)) : $this->fSize;
120120
return preg_replace(array("/$sPoint/", "/^(-?)0\./"), array('.', '$1.'), $sSize) . ($this->sUnit === null ? '' : $this->sUnit);
121121
}
122122

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,4 +704,10 @@ function testMicrosoftFilterParsing() {
704704
$sExpected = ".test {filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\"#80000000\",endColorstr=\"#00000000\",GradientType=1);}";
705705
$this->assertSame($sExpected, $oDoc->render());
706706
}
707+
708+
function testLargeSizeValuesInFile() {
709+
$oDoc = $this->parsedStructureForFile('large-z-index', Settings::create()->withMultibyteSupport(false));
710+
$sExpected = '.overlay {z-index: 10000000000000000000000;}';
711+
$this->assertSame($sExpected, $oDoc->render());
712+
}
707713
}

tests/files/large-z-index.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.overlay {
2+
z-index: 9999999999999999999999;
3+
}

0 commit comments

Comments
 (0)