diff --git a/lib/Sabberworm/CSS/Value/Size.php b/lib/Sabberworm/CSS/Value/Size.php index 05cf78c3..84628bf4 100644 --- a/lib/Sabberworm/CSS/Value/Size.php +++ b/lib/Sabberworm/CSS/Value/Size.php @@ -61,7 +61,7 @@ public function isRelative() { public function __toString() { $l = localeconv(); - return str_replace(array($l['decimal_point'], '0.'), '.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit); + return preg_replace(array('/' . preg_quote($l['decimal_point'], '/') . '/', '/^(-?)0\./'), '$1.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit); } } diff --git a/tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php b/tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php index a2d2b2fe..f2ddebd1 100644 --- a/tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php +++ b/tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php @@ -20,7 +20,7 @@ public function testFaultToleranceOn() { $sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css"; $oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true)); $oResult = $oParser->parse(); - $this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 200000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString()); + $this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 2000000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString()); } /** @@ -37,7 +37,7 @@ public function testLocaleTrap() { $sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "-fault-tolerance.css"; $oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true)); $oResult = $oParser->parse(); - $this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 200000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString()); + $this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 2000000000000.2;}'."\n".'#test {}'."\n".'#test2 {help: none;}'."\n", $oResult->__toString()); } public function testCaseInsensitivity() { diff --git a/tests/phpunit.xml b/tests/phpunit.xml new file mode 100644 index 00000000..5dcbab2b --- /dev/null +++ b/tests/phpunit.xml @@ -0,0 +1 @@ +