Skip to content

Commit

Permalink
merged branch bschussek/issue3161 (PR #3253)
Browse files Browse the repository at this point in the history
Commits
-------

9a4e22e [Form] Disallowed infinity in NumberToLocalizedStringTransformer

Discussion
----------

[Form] Disallowed infinity in NumberToLocalizedStringTransformer

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: #3161
Todo: -

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=issue3161)
  • Loading branch information
fabpot committed Feb 2, 2012
2 parents c6207e4 + 9a4e22e commit 0914a38
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
Expand Up @@ -114,6 +114,10 @@ public function reverseTransform($value)
throw new TransformationFailedException($formatter->getErrorMessage());
}

if ($value >= INF || $value <= -INF) {
throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like');
}

return $value;
}

Expand Down
Expand Up @@ -90,4 +90,24 @@ public function testReverseTransformDisallowsNaN2()

$transformer->reverseTransform('nan');
}

/**
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformDisallowsInfinity()
{
$transformer = new IntegerToLocalizedStringTransformer();

$transformer->reverseTransform('∞');
}

/**
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformDisallowsNegativeInfinity()
{
$transformer = new IntegerToLocalizedStringTransformer();

$transformer->reverseTransform('-∞');
}
}
Expand Up @@ -144,4 +144,34 @@ public function testReverseTransformDisallowsNaN2()

$transformer->reverseTransform('nan');
}

/**
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformDisallowsInfinity()
{
$transformer = new NumberToLocalizedStringTransformer();

$transformer->reverseTransform('∞');
}

/**
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformDisallowsInfinity2()
{
$transformer = new NumberToLocalizedStringTransformer();

$transformer->reverseTransform('∞,123');
}

/**
* @expectedException Symfony\Component\Form\Exception\TransformationFailedException
*/
public function testReverseTransformDisallowsNegativeInfinity()
{
$transformer = new NumberToLocalizedStringTransformer();

$transformer->reverseTransform('-∞');
}
}

0 comments on commit 0914a38

Please sign in to comment.