User tests: Successful: Unsuccessful:
Escape quote char in $db->quoteName()
method.
It can be considered as a little security fix,
but joomla (with correct sanitise aliases/columns) is secure also without this patch.
Code review or
Create and execute each query for specified database type:
$db = JFactory::getDbo();
$q1 = $db->getQuery(true)->select($db->quoteName('title', 'protected`title'))->from('#__content')->where('id=1');
// Without patch it generate error on mysql but it works on other databases
$db->setQuery($q1)->loadAssoc();
$db = JFactory::getDbo();
$q2 = $db->getQuery(true)->select($db->quoteName('title', 'protected"title'))->from('#__content')->where('id=1');
// Without patch it generate error on postgresql but it works on other databases
$db->setQuery($q2)->loadAssoc();
$db = JFactory::getDbo();
$q3 = $db->getQuery(true)->select($db->quoteName('title', 'protected]title'))->from('#__content')->where('id=1');
// Without patch it generate error on mssql but it works on other databases
$db->setQuery($q3)->loadAssoc();
SELECT title AS `protected``title` FROM #__content where id=1
SELECT title AS "protected""title" FROM #__content where id=1
SELECT title AS [protected]]title] FROM #__content where id=1
SELECT title AS `protected`title` FROM #__content where id=1
SELECT title AS "protected"title" FROM #__content where id=1
SELECT title AS [protected]title] FROM #__content where id=1
No
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Reviewed source code, and looks ok.
Based on MSSQL official doc at Microsoft, second case seems ok too:
https://technet.microsoft.com/en-us/library/ms176027(v=sql.105).aspx#
Great, but as usual we need 2 tests, I think that you review can be used as success test.
You can mark it as success at https://issues.joomla.org/tracker/joomla-cms/13825
I have tested this item
Tested on MySQL.
I have tested this item
on mssql
on postgresql
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-02-02 14:32:03 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
With a small degree of trepidation given previous attempts to modify this function. Merged
With a small degree of trepidation given previous attempts to modify this function. Merged
Surely then its a good candidate for unit tests?
Then I will add a new PR with tests for quoteName
for 3 dbs which will be tested by appveyor.
To quote someone else (@mbabker):