Mailing List
Home
Forum Home
MySQL General - General MySQL discussion
MySQL++ - Programming with the C++ API to MySQL
MaxDB - Everything about MaxDB, formerly known as SAP DB
ODBC - ODBC with the MySQL Connector/ODBC driver
MySQL on Win32 - Runing MySQL on Windows 9x/Me/NT/2000/XP
Java Help - Mostly related to the MySQL Connector/J driver
Perl - Perl support for MySQL with DBI and DBD::mysql
GUI - MySQL GUI Tools
Announcement
Subjects
mysql openssl Question
ERROR 1045: Access denied for user: 'root@localhost ' (Using
password: NO)
Update one field with more fields from another table
Getting Identity after INSERT
ERROR 2002: Can 't connect to local MySQL server through socket
mysql test 4 1 fails with the gis test
MySQL Cluster Software
Downgrade Mysql from 4 to 3 23
Mysql 4 0 Oracle Stored Procedure Trigger Conversion
Can 't access mysql after kernel upgrade
Executing MySQL Commands From Within C Program
Comparing and writing out BLOBS
Preventing Duplicate Entries
FULLTEXT query format question
Strange behavior, Table Level Permission
Does the binary log enabling affect the MySQL performances?
mysql:it 's a db not a dbms how it 's possible?!
mysql have same function mthod as Oracle decode()
 
Bug: char[]s not escaped

Bug: char[]s not escaped

2007-07-01       - By Andrew Sayers

 Back
Reply:     1     2     3     4     5     6  

Tested against 2.2.3, mysqlpp::quote and mysqlpp::escape don't escape
text passed as an array of characters:

#include <mysql++.h>
#include <iostream>

using namespace std;
using namespace mysqlpp;

int main() {
  string s1 = "Frank's Brand Hotdog Buns";
  std::cout << quote << s1 << std::endl;
  // Output: 'Frank\'s Brand Hotdog Buns'

  char s2[] = "Frank's Brand Hotdog Buns";
  std::cout << quote << s2 << std::endl;
  // Output: Frank's Brand Hotdog Buns

}


C++ prefers to use the template functions rather than converting a
char[] to a char*.  Here's a patch:


--- manip-old.h   2007-05-08 00:49:32.000000000 +0100
+++ manip.h   2007-07-02 01:35:45.000000000 +0100
@@ -170,6 +170,18 @@
  return operator <<(o, const_cast<const char* const&>(in));
}

+inline std::ostream& operator <<(quote_type1 o,
+     char in[])
+{
+   return operator <<(o, const_cast<const char* const&>(in));
+}
+
+inline std::ostream& operator <<(quote_type1 o,
+     const char in[])
+{
+   return operator <<(o, const_cast<const char* const&>(in));
+}
+

template <>
inline std::ostream& operator <<(quote_type1 o,
@@ -540,6 +552,18 @@
  return operator <<(o, const_cast<const char* const&>(in));
}

+inline std::ostream& operator <<(escape_type1 o,
+     char in[])
+{
+   return operator <<(o, const_cast<const char* const&>(in));
+}
+
+inline std::ostream& operator <<(escape_type1 o,
+     const char in[])
+{
+   return operator <<(o, const_cast<const char* const&>(in));
+}
+

/// \enum do_nothing_type0
/// \anchor do_nothing_manip


--
MySQL++ Mailing List
For list archives: http://lists.mysql.com/plusplus
To unsubscribe:    http://lists.mysql.com/plusplus?unsub=mysql@(protected)