Merge branch '17.0' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
f02ff3f774
@ -484,7 +484,7 @@ class DoliDBMysqli extends DoliDB
|
|||||||
*/
|
*/
|
||||||
public function escapeforlike($stringtoencode)
|
public function escapeforlike($stringtoencode)
|
||||||
{
|
{
|
||||||
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
|
return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -729,7 +729,7 @@ class DoliDBPgsql extends DoliDB
|
|||||||
*/
|
*/
|
||||||
public function escapeforlike($stringtoencode)
|
public function escapeforlike($stringtoencode)
|
||||||
{
|
{
|
||||||
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
|
return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -657,7 +657,7 @@ class DoliDBSqlite3 extends DoliDB
|
|||||||
*/
|
*/
|
||||||
public function escapeforlike($stringtoencode)
|
public function escapeforlike($stringtoencode)
|
||||||
{
|
{
|
||||||
return str_replace(array('_', '\\', '%'), array('\_', '\\\\', '\%'), (string) $stringtoencode);
|
return str_replace(array('\\', '_', '%'), array('\\\\', '\_', '\%'), (string) $stringtoencode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -157,6 +157,44 @@ class CodingSqlTest extends PHPUnit\Framework\TestCase
|
|||||||
print __METHOD__."\n";
|
print __METHOD__."\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testEscape
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function testEscape()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$a = 'abc"\'def';
|
||||||
|
print $a;
|
||||||
|
$result = $db->escape($a); // $result must be abc\"\'def
|
||||||
|
$this->assertEquals('abc\"\\\'def', $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testEscapeForLike
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function testEscapeForLike()
|
||||||
|
{
|
||||||
|
global $conf,$user,$langs,$db;
|
||||||
|
$conf=$this->savconf;
|
||||||
|
$user=$this->savuser;
|
||||||
|
$langs=$this->savlangs;
|
||||||
|
$db=$this->savdb;
|
||||||
|
|
||||||
|
$a = 'abc"\'def_ghi%klm\\nop';
|
||||||
|
//print $a;
|
||||||
|
$result = $db->escapeforlike($a); // $result must be abc"'def\_ghi\%klm\\nop
|
||||||
|
$this->assertEquals('abc"\'def\_ghi\%klm\\\\nop', $result);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testSql
|
* testSql
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user