-
-
Notifications
You must be signed in to change notification settings - Fork 436
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
Strip null bytes from strings and filter conditions. #1430
Conversation
To wake up this PR, I like my old idea #832. |
@luigifab null bytes and leading/trailing whitespace are quite different situations and fixing one doesn't affect the other.. I don't know of any cases where someone needs leading or trailing whitespace in the context of Magento, I've never seen one, but it is somewhat plausible so I actually don't disagree with #832. However, I don't think it is plausible that a user wants to insert a null byte somewhere unless said user is a hacker. 😆 But again, these are two different solutions to two different problems in my opinion. |
I cannot find the ref issue. |
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.
Please check.
Sorry, @kiatng, I honestly cannot recall what the ref'd issue was or why I didn't provide a full link to it.. 😞 |
It appears as though this change broke all my grids. When filtering none have any results (except ironically when the new This appears to be due to: # lib/Varien/Db/Adapter/Pdo/Mysql.php
/**
* Prepare Sql condition
*
* @param string $text Condition value
* @param mixed $value
* @param string $fieldName
* @return string
*/
protected function _prepareQuotedSqlCondition($text, $value, $fieldName)
{
$sql = $this->quoteInto($text, str_replace("\0", '', $value));
return str_replace('{{fieldName}}', $fieldName, $sql);
} In the context for grid filters such as Product, previously, The This leads to something like this when filtering product name for $text = "at_name.value LIKE ?";
$value = new Zend_Db_Expr("'%Dog%'");
$fieldName = "at_name.value";
$text_rpl = str_replace('{{fieldName}}', $fieldName, $text);
$old = $this->quoteInto($text_rpl, $value);
# $old: "at_name.value LIKE '%Dog%'"
$sql = $this->quoteInto($text, str_replace("\0", '', $value));
$new = str_replace('{{fieldName}}', $fieldName, $sql);
# $new: "at_name.value LIKE '\'%Dog%\''" |
If it is a confirmed bug, it must be reverted quickly. Later a new PR can be created to solve the issue. |
This reverts commit 9a49aa1.
I've created a PR to revert this one, just so that we don't forget about it. In the meanwhile let's wait for @colinmollenhour to comment :-) |
Change
to
should work. |
Ahh, sorry everyone.. I forgot about |
Imho ... If it is a confirmed bug - in an already released version - we should either revert OR fix it quickly in a hotfix-release. If it is a confirmed bug - in 1.9.4.x/dev-branch - we should fix it quickly before next release. |
Description (*)
Prevent null bytes injected into user-provided data from being included in saved data and query filters.
Fixed Issues (if relevant)
Related to #1087590
Questions or comments
Blob types are not affected, only varchar and text types. I've never seen any reason why Magento should store null bytes in varchar or text columns but please advise if you can think of any.
Contribution checklist (*)