fix(Om): fix updateCollection/set() when string contains SQL operators#271
Open
Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Open
fix(Om): fix updateCollection/set() when string contains SQL operators#271Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Conversation
- Remove isConditionalClause check in set() that incorrectly treated string values with SQL keywords (IN, LIKE, BETWEEN, =) as raw SQL expressions - String fields are now always quoted via PARAM_STR, preventing both incorrect query construction and SQL injection - Add null type handling in driver-specific construct() for robustness - Add test cases for LIKE, BETWEEN, =, empty string, and apostrophe - Add descriptive names to providerUpdateCollection data sets Fixes modxcms#54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix updateCollection/set() when string value contains SQL operator keywords (e.g. IN, LIKE)
Previously,
xPDOQuery::set()usedisConditionalClause()to detect raw SQL expressions. String values containing SQL keywords like "IN", "LIKE", "BETWEEN", or "=" were incorrectly treated as raw SQL and not quoted, causing malformed queries and potential SQL injection.Changes:
isConditionalClausecheck inset()— string fields are now always treated asPARAM_STRand properly quotedelseif (in_array(...))withelseconstruct()for robustnessproviderUpdateCollectiondata sets for clearer failure messagesSecurity: Proper quoting via
quote()reduces SQL injection risk.isConditionalClauseremains used inwhere()and other places where SQL expressions are expected.Fixes #54