Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 02ab72a

Browse filesBrowse files
tigr1991nicolas-grekas
authored andcommitted
[ExpressionLanguage][Node][BinaryNode] Process division by zero
1 parent a054d88 commit 02ab72a
Copy full SHA for 02ab72a

File tree

Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-1
lines changed

‎src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/ExpressionLanguage/Node/BinaryNode.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,16 @@ public function evaluate($functions, $values)
147147
case '*':
148148
return $left * $right;
149149
case '/':
150+
if (0 == $right) {
151+
throw new \DivisionByZeroError('Division by zero');
152+
}
153+
150154
return $left / $right;
151155
case '%':
156+
if (0 == $right) {
157+
throw new \DivisionByZeroError('Modulo by zero');
158+
}
159+
152160
return $left % $right;
153161
case 'matches':
154162
return preg_match($right, $left);

‎src/Symfony/Component/ExpressionLanguage/composer.json

Copy file name to clipboardExpand all lines: src/Symfony/Component/ExpressionLanguage/composer.json
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
],
1818
"require": {
1919
"php": "^5.5.9|>=7.0.8",
20-
"symfony/cache": "~3.1|~4.0"
20+
"symfony/cache": "~3.1|~4.0",
21+
"symfony/polyfill-php70": "~1.6"
2122
},
2223
"autoload": {
2324
"psr-4": { "Symfony\\Component\\ExpressionLanguage\\": "" },

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.