Conversation
…rds compatibility Co-authored-by: fiammybe <3736946+fiammybe@users.noreply.github.com>
Co-authored-by: fiammybe <3736946+fiammybe@users.noreply.github.com>
Co-authored-by: fiammybe <3736946+fiammybe@users.noreply.github.com>
Co-authored-by: fiammybe <3736946+fiammybe@users.noreply.github.com>
|
The pattern is also what I had come up with - wasn't sure how to test the NUL (not a typo - it's how it's referred to elsewhere) character, though. 1 question - the method signature defines the 2nd parameter as null. Could you just put the default pattern there and not have to do any other defining and testing? |
|
Well, we would have to make other changes to have a non-NULL default for the parameter. I encountered this when just replacing null with the string:
|
skenow
left a comment
There was a problem hiding this comment.
This does solve the issue and preserves the type hinting in the method signature.
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
User description
icms_core_DataFilter::addSlashes()was callingaddcslashes()without default characters, causing it to escape nothing when invoked without the second parameter. This broke SQL queries with single quotes, triggered false Protector SQL injection warnings, and caused unexpected character conversions during save operations.Changes
DEFAULT_ESCAPE_CHARSconstant containing',",\, and\0(NUL byte) to match PHP'saddslashes()behavioraddSlashes()to use the constant when$paramisnull, providing backwards compatibility while preserving the ability to specify custom character listsmagic_quotes_gpcreferencesExample
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
PR Type
Bug fix, Enhancement
Description
Add DEFAULT_ESCAPE_CHARS constant matching PHP's addslashes() behavior
Fix addSlashes() to escape single quotes, double quotes, backslashes, NUL bytes by default
Improve method documentation and remove obsolete magic_quotes_gpc references
Maintain backwards compatibility while allowing custom character escaping
Diagram Walkthrough
File Walkthrough
DataFilter.php
Add default escape characters constant and fix addSlashes methodhtdocs/libraries/icms/core/DataFilter.php
double quote, backslash, and NUL byte characters
is null
obsolete magic_quotes_gpc references
addslashes()