Skip to content

Commit

Permalink
[BUGFIX] Prevent possible division par zero
Browse files Browse the repository at this point in the history
  • Loading branch information
xperseguers committed Dec 2, 2022
1 parent df37b6b commit 38dde2d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Classes/Utility/Number.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

namespace Causal\Extractor\Utility;

use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Number utility class.
*
Expand Down Expand Up @@ -58,7 +56,8 @@ public static function extractIntegerAtEnd(?string $str = null): ?int
public static function extractFloat(?string $str = null): float
{
if (preg_match('#^(\d+)/(\d+)$#', $str, $matches)) {
$value = (int)$matches[1] / (float)$matches[2];
$divisor = (float)$matches[2];
$value = (int)$matches[1] / ($divisor > 0 ? $divisor : 1);
} elseif (preg_match('/35 mm equivalent: (\d+\.\d+) mm/', $str, $matches)) {
$value = (float)$matches[1];
} else {
Expand Down

0 comments on commit 38dde2d

Please sign in to comment.