-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
[2.x] Escape single-quotes from SOQLConnection #107
base: master
Are you sure you want to change the base?
[2.x] Escape single-quotes from SOQLConnection #107
Conversation
Hey @roblesterjr04! 👋 Sorry to bother, just wanted to see if you had a chance to check this out. Any thoughts/feedback? |
Hi Casey, i just haven't had time to review it in depth. Have you run the unit tests on your machine? |
I've meet a problem which I think can be solved by this. I need to query some data and filter using this value I overcome it with the following code
|
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's a missing parentesis on line 158
@@ -155,6 +155,8 @@ public function prepareBindings(array $bindings) | |||
$bindings[$key] = $value->format($grammar->getDateFormat()); | |||
} else if (is_bool($value)) { | |||
$bindings[$key] = $value ? 'TRUE' : 'FALSE'; | |||
} else if (is_string($value) { |
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 is a missing ) here. it should be } else if (is_string($value)) {
@roblesterjr04 revisiting this bit from #95 tonight, and I'm pretty sure #96 doesn't actually solve the underlying problem.
I've continued to get SOQL errors related to unescaped quotes. As far as I can tell, the
toSql
method inside ofSOQLBuilder.php
never actually gets called, at least not onSELECT
queries. Eg, you can chuck add('won't ever show');
into the top of that method, hit a page or endpoint that calls a select query, and it will go through without dumping. This might be anecdotal, but at least on simple tests I ran, it's never getting called.I think what's happening with that
SOQLBuilder
class, is that it's intending to override thetoSql
method from its parent...butSOQLBuilder
extends the Eloquent Builder, not the Query Builder, and thattoSql
method exists on the latter. It therefore never gets called on the former, which means theSOQLBuilder
's override never gets called either. This is handled via the$passthru
property from the Eloquent Builder, which (via thetoBase()
method) hands off calls liketoSql
down to the Query Builder.Definitely wouldn't put money on this, but I suspect you could delete that entire
toSql
method fromSOQLBuilder
, and nothing would break, as I just don't think it gets called anywhere (except maybe inSOQLBatch
).Will defer to you on any changes to that class, though—this PR doesn't touch it.
So TL;DR - this PR essentially takes the patch in #96, and relocates it to the
SOQLConnection->prepareBindings()
method with anis_string
check, where it actually gets called & applied.I would definitely give this all a thorough review, though, as I think there might be some security considerations with how
'
and similar characters are able to be passed in? Dunno, that's not my forte, so I defer to your expertise. 🙂 That said, let me know if there's anything you'd like to see modified with this PR; happy to help where I can.