Skip to content

Commit 9dee32a

Browse files
committed
Merge remote-tracking branch 'slusarz/float_fix'
* slusarz/float_fix: Fix Size output for locales that use non-period decimal separators Closes MyIntervals#61 as fixed
2 parents 34fcc74 + 1fe2959 commit 9dee32a

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
* *No backwards-incompatible changes*
3232
* *No deprecations*
3333

34+
### 5.0.4 (2013-03-21)
35+
36+
* Don’t output floats with locale-aware separator chars
37+
* *No backwards-incompatible changes*
38+
* *No deprecations*
39+
3440
## 4.0
3541

3642
### 4.0.0 (2013-03-19)

lib/Sabberworm/CSS/Value/Size.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public function isRelative() {
6060
}
6161

6262
public function __toString() {
63-
return str_replace('0.', '.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
63+
$l = localeconv();
64+
return str_replace(array($l['decimal_point'], '0.'), '.', $this->fSize) . ($this->sUnit === null ? '' : $this->sUnit);
6465
}
6566

6667
}

tests/Sabberworm/CSS/RuleSet/LenientParsingTest.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ public function testFaultToleranceOn() {
2020
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "fault-tolerance.css";
2121
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
2222
$oResult = $oParser->parse();
23-
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2;}'."\n", $oResult->__toString());
23+
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 200000000000.2;}'."\n", $oResult->__toString());
24+
}
25+
26+
public function testLocaleTrap() {
27+
setlocale(LC_ALL, "pt_PT", "no");
28+
$sFile = dirname(__FILE__) . '/../../../files' . DIRECTORY_SEPARATOR . "fault-tolerance.css";
29+
$oParser = new Parser(file_get_contents($sFile), Settings::create()->withLenientParsing(true));
30+
$oResult = $oParser->parse();
31+
$this->assertSame('.test1 {}'."\n".'.test2 {hello: 2.2;hello: 200000000000.2;}'."\n", $oResult->__toString());
2432
}
2533

2634
public function testCaseInsensitivity() {

tests/files/fault-tolerance.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
.test2 {
66
*hello: 1;
7-
hello: 2;
7+
hello: 2.2;
8+
hello: 2000000000000.2;
89
}

0 commit comments

Comments
 (0)