- Adding TYPE_BIN and support for it in api.php
authorRobert Sesek <rsesek@bluestatic.org>
Sat, 20 May 2006 18:07:14 +0000 (18:07 +0000)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 20 May 2006 18:07:14 +0000 (18:07 +0000)
- Escaping binary now works in db_mysql.php

api.php
db_mysql.php
dev/changes.txt
kernel.php

diff --git a/api.php b/api.php
index a2c9c9733cbfae813f23a0fd47c5cfadf4176e6c..058f98b0d21f905f319432a2e381e8b3de1c6f21 100644 (file)
--- a/api.php
+++ b/api.php
@@ -593,12 +593,16 @@ class API
                
                if ($type == TYPE_NOCLEAN OR $type == TYPE_STR OR $type == TYPE_STRUN)
                {
-                       return "'" . $this->registry->escape($this->values["$name"]) . "'";
+                       return "'" . $this->registry->db->escape_string($this->values["$name"]) . "'";
                }
                else if ($type == TYPE_BOOL)
                {
                        return ($this->values["$name"] == true ? "'1'" : "'0'");
                }
+               else if ($type == TYPE_BIN)
+               {
+                       return "'" . $this->registry->db->escape_binary($this->values["$name"]) . "'";
+               }
                else
                {
                        return $this->values["$name"];
index 2cee356b2fe27490679cde8b952d7dd48b75e938..8d1b3415e693dd4fdfc1d44c36af87e6e7d695e9 100644 (file)
@@ -54,6 +54,7 @@ class DB_MySQL extends DB_Abstract
                'error_num'                     => 'mysql_errno',
                'error_str'                     => 'mysql_error',
                'escape_string'         => '$this->command_mysql_escape_string',
+               'escape_binary'         => '$this->escape_binary',
                'fetch_assoc'           => 'mysql_fetch_assoc',
                'fetch_row'                     => 'mysql_fetch_row',
                'fetch_object'          => 'mysql_fetch_object',
@@ -156,6 +157,21 @@ class DB_MySQL extends DB_Abstract
                return mysql_query($string, $link);
        }
        
+       // ###################################################################
+       /**
+       * Escapes a binary string for insertion into the database
+       *
+       * @access       public
+       *
+       * @param        string  Unescaped data
+       *
+       * @return       string  Escaped binary data
+       */
+       function escape_binary($binary)
+       {
+               return mysql_escape_string($binary);
+       }
+       
        // ###################################################################
        /**
        * Wrapper: mysql(_real)_escape_string
index 2b2d9bad0a6cc6888d48360ef21438d5a10c4bf2..cb8bd8214194df5270d4ac0c242015e2d8a7aa23 100644 (file)
@@ -1,6 +1,8 @@
 2.0.1
 ===============
-- Add TYPE_NONE as an alias for TYPE_NOCLEAN
+- Added TYPE_NONE as an alias for TYPE_NOCLEAN
+- Added TYPE_BIN to create a macro in the API that will escape the string as binary, instead of a string
+- DB_MySQL can now properly escape binary
 
 2.0.0
 ===============
index 7202336875d720121eca1ec41906f2e1eb8866d9..b5dc718296afb5a119f570996437b74a6e419dc1 100644 (file)
@@ -127,6 +127,11 @@ define('TYPE_NOCLEAN', 64);
 * Duplicate of TYPE_NOCLEAN, but shorter
 */
 define('TYPE_NONE', TYPE_NOCLEAN);
+
+/**
+* Macro for using DB->escape_binary() without cleaning - used in API
+*/
+define('TYPE_BIN', 128);
 /**#@-*/
 
 /**
@@ -1128,6 +1133,10 @@ class ISSO
                                $value = $value;
                        }
                }
+               else if ($type == TYPE_BIN)
+               {
+                       $value = $value;
+               }
                else
                {
                        trigger_error('Invalid clean type `' . $type . '` specified', E_USER_ERROR);