diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index a5ad4e7134..bc12cce8aa 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -71,8 +71,9 @@ p,ul,td {font-size:10pt;}
[Fix] added session keys table to backup
[Fix] changes to support MySQL 5.0
[Fix] changes to some of the admin files to improve efficiency and remove a potential error condition when building the menu (cxib)
-[Fix] change truncation of username length in usercp_register.php (BFUK)
+[Fix] change truncation of username length in usercp_register.php - BFUK
[Fix] incorrect path to avatars in admin_users.php (Bug #667)
+[Fix] fixed get_userdata to support correct sql escaping (non-mysql dbs) - jarnaez
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 993b194df8..8c24488981 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -158,7 +158,7 @@ function get_userdata($user, $force_str = false)
$sql = "SELECT *
FROM " . USERS_TABLE . "
WHERE ";
- $sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" . $user . "'" ) . " AND user_id <> " . ANONYMOUS;
+ $sql .= ( ( is_integer($user) ) ? "user_id = $user" : "username = '" . str_replace("\'", "''", $user) . "'" ) . " AND user_id <> " . ANONYMOUS;
if ( !($result = $db->sql_query($sql)) )
{
message_die(GENERAL_ERROR, 'Tried obtaining data for a non-existent user', '', __LINE__, __FILE__, $sql);