-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix db escape negative integers #5277
Fix db escape negative integers #5277
Conversation
system/Database/BaseConnection.php
Outdated
@@ -1201,7 +1203,7 @@ public function escape($str) | |||
} | |||
|
|||
if (is_numeric($str) && $str < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is there a need to add this for negative numbers? I think we can remove this if block entirely as the last return will do the job.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And it seems inconsistent, with negative numbers we get a string. For positive, we get numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!
For now, I remove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's have @lonnieezell shed the light on this. 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't remember exactly. It's been 4 years :) . Looking back through the issue, though, I'm guessing that wrapping it in quotes would get it past the escaping and adding of the slash, which was then converted by MySQL into an INT or whatever type when it was saved to the table.
I would say as long as we have tests in place that ensure his problem is still fixed, and it doesn't escape the negative sign, this is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lonnieezell Thanks!
e3571ae
to
b009bfd
Compare
@@ -40,7 +40,7 @@ protected function setUp(): void | |||
*/ | |||
public function testEscapeProtectsNegativeNumbers() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be renamed to say that this does not escape negative numbers now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
It is inconsistent, with negative numbers we get a string. For positive, we get numbers.
b009bfd
to
127b9cf
Compare
Description
Fixes #4973
Checklist: