PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB » Bug #1231

Wrong escaping of ampersand char '&'

Details

Submitted2004-04-17 18:36 UTC
Fromsignup at cheapweb dot it
Assigneddanielc
StatusBogus
PackageDB
PHP Version4.3.4
OSLinux
Roadmaps(Not assigned)

Comments

[2004-04-17 18:36 UTC] signup at cheapweb dot it

Description:
------------
It seems to be a deficiency in the field escaping mechanism when I use DB::prepare() and DB::execute(). If data in a field contains an ampersand ('&') the char is (wrongly) escaped. Actually the ampersand should not be escaped at all.

The commented code wich does the same work of DB::prepare() and DB::execute() statements works fine -

Reproduce code:
---------------
// $statement = "INSERT INTO visualmedia (visualmedia_nome, visualmedia_idEvento, visualmedia_categoria, " . "visualmedia_dir, visualmedia_width, visualmedia_height, visualmedia_data, " .
"visualmedia_tipo) " .
"VALUES ('{$row[0]}', '$idEvento', '$categoria', '$dir', '{$row[1]}', " .
"'{$row[2]}', '{$row[3]}', '{$row[4]}')";
// $res = $dbh->query($statement);
// $statement = "INSERT INTO visualmedia (visualmedia_nome, visualmedia_idEvento, visualmedia_categoria, " . "visualmedia_dir, visualmedia_width, visualmedia_height, visualmedia_data, " .
"visualmedia_tipo) " .
"VALUES (?, '$idEvento', '$categoria', '$dir', ?, " .
"?, ?, ?)";
$dbh->prepare($statement);
$res = $dbh->execute($sth, $row);

Expected result:
----------------
A valid query

Actual result:
--------------
Suppose that $row[1] == 'x&y' it becomes escaped as 'x\\&y' wich leads to an unsuccesful query