|
From: <asf...@us...> - 2011-06-04 18:43:17
|
Revision: 53115
http://firebird.svn.sourceforge.net/firebird/?rev=53115&view=rev
Author: asfernandes
Date: 2011-06-04 18:43:10 +0000 (Sat, 04 Jun 2011)
Log Message:
-----------
Backport fix for CORE-3511 - Unquoted role names with non-ASCII characters passed in DPB are upper-cased wrongly.
Modified Paths:
--------------
firebird/branches/B2_5_Release/doc/WhatsNew
firebird/branches/B2_5_Release/src/jrd/IntlUtil.cpp
firebird/branches/B2_5_Release/src/jrd/IntlUtil.h
firebird/branches/B2_5_Release/src/jrd/jrd.cpp
Modified: firebird/branches/B2_5_Release/doc/WhatsNew
===================================================================
--- firebird/branches/B2_5_Release/doc/WhatsNew 2011-06-04 18:42:37 UTC (rev 53114)
+++ firebird/branches/B2_5_Release/doc/WhatsNew 2011-06-04 18:43:10 UTC (rev 53115)
@@ -7,6 +7,11 @@
Contributor(s):
Alex Peshkov <peshkoff at mail.ru>
+ * Bugfix CORE-3511
+ Unquoted role names with non-ASCII characters passed in DPB are upper-cased wrongly.
+ Contributor(s):
+ Adriano dos Santos Fernandes <adrianosf at uol.com.br>
+
* Bugfix CORE-3508
MON$DATABASE_NAME and MON$ATTACHMENT_NAME fields contain question marks
instead of non-ASCII characters regardless of the connection charset
Modified: firebird/branches/B2_5_Release/src/jrd/IntlUtil.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/IntlUtil.cpp 2011-06-04 18:42:37 UTC (rev 53114)
+++ firebird/branches/B2_5_Release/src/jrd/IntlUtil.cpp 2011-06-04 18:43:10 UTC (rev 53115)
@@ -74,6 +74,15 @@
ULONG dstLen, UCHAR* dst);
+GlobalPtr<IntlUtil::Utf8CharSet> IntlUtil::utf8CharSet;
+
+IntlUtil::Utf8CharSet::Utf8CharSet(MemoryPool& pool)
+{
+ IntlUtil::initUtf8Charset(&obj);
+ charSet = Jrd::CharSet::createInstance(pool, CS_UTF8, &obj);
+}
+
+
string IntlUtil::generateSpecificAttributes(Jrd::CharSet* cs, SpecificAttributesMap& map)
{
SpecificAttributesMap::Accessor accessor(&map);
@@ -557,6 +566,19 @@
}
+void IntlUtil::toUpper(Jrd::CharSet* cs, string& s)
+{
+ HalfStaticArray<UCHAR, BUFFER_SMALL> buffer;
+ size_t len = s.length();
+ ULONG count = toUpper(cs, len, (const UCHAR*) s.c_str(), len * 4, buffer.getBuffer(len * 4), NULL);
+
+ if (count != INTL_BAD_STR_LENGTH)
+ s.assign((const char*) buffer.begin(), count);
+ else
+ fb_assert(false);
+}
+
+
bool IntlUtil::readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size)
{
(*s) += *size;
Modified: firebird/branches/B2_5_Release/src/jrd/IntlUtil.h
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/IntlUtil.h 2011-06-04 18:42:37 UTC (rev 53114)
+++ firebird/branches/B2_5_Release/src/jrd/IntlUtil.h 2011-06-04 18:43:10 UTC (rev 53115)
@@ -28,8 +28,10 @@
#define JRD_INTLUTIL_H
#include "../common/classes/array.h"
+#include "../common/classes/auto.h"
#include "../common/classes/GenericMap.h"
#include "../common/classes/fb_string.h"
+#include "../common/classes/init.h"
#include "../jrd/intlobj_new.h"
namespace Jrd
@@ -46,6 +48,11 @@
typedef GenericMap<SpecificAttribute> SpecificAttributesMap;
public:
+ static Jrd::CharSet* getUtf8CharSet()
+ {
+ return utf8CharSet->charSet;
+ }
+
static string generateSpecificAttributes(Jrd::CharSet* cs, SpecificAttributesMap& map);
static bool parseSpecificAttributes(Jrd::CharSet* cs, ULONG len, const UCHAR* s,
SpecificAttributesMap* map);
@@ -77,6 +84,7 @@
const ULONG* exceptions);
static ULONG toUpper(Jrd::CharSet* cs, ULONG srcLen, const UCHAR* src, ULONG dstLen, UCHAR* dst,
const ULONG* exceptions);
+ static void toUpper(Jrd::CharSet* cs, string& s);
static bool readOneChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size);
@@ -91,6 +99,19 @@
static bool readAttributeChar(Jrd::CharSet* cs, const UCHAR** s, const UCHAR* end, ULONG* size,
bool returnEscape);
+
+private:
+ class Utf8CharSet
+ {
+ public:
+ Utf8CharSet(MemoryPool& pool);
+
+ public:
+ charset obj;
+ AutoPtr<Jrd::CharSet> charSet;
+ };
+
+ static GlobalPtr<Utf8CharSet> utf8CharSet;
};
} // namespace Firebird
Modified: firebird/branches/B2_5_Release/src/jrd/jrd.cpp
===================================================================
--- firebird/branches/B2_5_Release/src/jrd/jrd.cpp 2011-06-04 18:42:37 UTC (rev 53114)
+++ firebird/branches/B2_5_Release/src/jrd/jrd.cpp 2011-06-04 18:43:10 UTC (rev 53115)
@@ -1082,6 +1082,8 @@
{
attachment->att_requested_role = userId.usr_sql_role_name;
+ CharSet* utf8CharSet = IntlUtil::getUtf8CharSet();
+
switch (options.dpb_sql_dialect)
{
case 0:
@@ -1120,7 +1122,7 @@
case SQL_DIALECT_V5:
{
strip_quotes(userId.usr_sql_role_name);
- userId.usr_sql_role_name.upper();
+ IntlUtil::toUpper(utf8CharSet, userId.usr_sql_role_name);
}
break;
case SQL_DIALECT_V6_TRANSITION:
@@ -1151,9 +1153,7 @@
}
}
else
- {
- role.upper();
- }
+ IntlUtil::toUpper(utf8CharSet, role);
}
break;
default:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|