[2.x] Escape single-quotes from SOQLConnection #107
+2
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@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.