Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Zend\Db Fix for #3290 #3584

Merged
merged 1 commit into from

3 participants

@ralphschindler
Collaborator

Zend\Db\Adapter\Platform\Mysql should have wider rage of possible identifiers in fragment quoting.
See #3290

@ralphschindler ralphschindler Zend\Db Fix for #3290
- Zend\Db\Adapter\Platform\Mysql should have wider rage of possible identifiers in fragment quoting
1e5f232
@weierophinney weierophinney merged commit 1e5f232 into zendframework:develop

1 check passed

Details default The Travis build passed
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3584' into develop
Close #3584
9c8f411
@turrsis

To my mind this is a little wrong fix, because using the permitted characters in UNQUOTED identifiers.
See #4769

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 28, 2013
  1. @ralphschindler

    Zend\Db Fix for #3290

    ralphschindler authored
    - Zend\Db\Adapter\Platform\Mysql should have wider rage of possible identifiers in fragment quoting
This page is out of date. Refresh to see the latest.
View
3  library/Zend/Db/Adapter/Platform/Mysql.php
@@ -113,7 +113,8 @@ public function getIdentifierSeparator()
*/
public function quoteIdentifierInFragment($identifier, array $safeWords = array())
{
- $parts = preg_split('#([\.\s\W])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
+ // regex taken from @link http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
+ $parts = preg_split('#([^0-9,a-z,A-Z$_])#', $identifier, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ($parts as $i => $part) {
if ($safeWords && in_array($part, $safeWords)) {
continue;
View
1  tests/ZendTest/Db/Adapter/Platform/MysqlTest.php
@@ -108,6 +108,7 @@ public function testQuoteIdentifierInFragment()
{
$this->assertEquals('`foo`.`bar`', $this->platform->quoteIdentifierInFragment('foo.bar'));
$this->assertEquals('`foo` as `bar`', $this->platform->quoteIdentifierInFragment('foo as bar'));
+ $this->assertEquals('`$TableName`.`bar`', $this->platform->quoteIdentifierInFragment('$TableName.bar'));
}
/**
Something went wrong with that request. Please try again.