Hello,

Attached is a patch to fix a bug I've been hitting.

Thanks,

Josh
From e9f313e6258d740cd908b7d37c8082101e4757aa Mon Sep 17 00:00:00 2001
From: Joshua Roys <[email protected]>
Date: Wed, 20 Jan 2010 11:38:56 -0500
Subject: [PATCH] 528214 - Encode DBstrings as utf-8 bytes before truncating

If they are left as utf-8 strings and not converted to their
corresponding byte sequence, python treats a multi-byte utf-8
character as one unit.  This causes confusion for things like
splices, especially the one right below this patch; that splice
tries to limit the length of the string to the maximum supported
by the database schema, but fails to do so as it is operating on
a utf-8 string rather than a byte string.

Side note:  NLS_LANG must be set to an appropriate utf-8 locale.
---
 backend/server/importlib/backendLib.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/backend/server/importlib/backendLib.py 
b/backend/server/importlib/backendLib.py
index b7e4145..2542383 100644
--- a/backend/server/importlib/backendLib.py
+++ b/backend/server/importlib/backendLib.py
@@ -464,6 +464,8 @@ def sanitizeValue(value, datatype):
     if isinstance(datatype, DBstring):
         if value is None:
             value = ''
+        if isinstance(value, unicode):
+            value = unicode.encode(value, 'utf-8')
         return value[:datatype.limit]
     if isinstance(datatype, DBblob):
         if value is None:
-- 
1.6.5.2

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel

Reply via email to